PHP 7.3是PHP最新的穩定版本。本文將給大家介紹如何在CentOS和Redhat 6.10系統上安裝PHP 7.3、PHP 7.2、PHP 7.1。
配置yum庫
首先,需要在系統上啟用Remi和EPEL yum存儲庫。使用以下命令在CentOS和Red Hat 7/6系統上安裝EPEL存儲庫
使用此命令安裝epel-release yum存儲庫
# yum install epel-release
現在根據你的操作系統版本執行以下命令之一來安裝Remi 存儲庫。
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
在CentOS 6上安裝PHP 7
你的系統已經為從yum存儲庫安裝PHP做好了準備。根據需要,使用以下命令之一在系統上安裝PHP 7.3或PHP 7.2或PHP 7.1。
- ## 安裝PHP 7.3
- $ yum --enablerepo=remi-php73 install php
- ## 安裝PHP 7.2
- $ yum --enablerepo=remi-php72 install php
- ## 安裝PHP 7.1
- $ yum --enablerepo=remi-php71 install php
我已經在我的系統上安裝了最新版本的PHP 7.3?,F在運行以下命令來檢查系統的當前使用的PHP版本。
- $ php -v
- PHP 7.3.0 (cli) (built: Dec 4 2018 16:12:20) ( NTS )
- Copyright (c) 1997-2018 The PHP Group
- Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
安裝PHP模塊
你還可能需要根據你的應用程序需求安裝額外的PHP模塊。
下面的命令將安裝一些有用的PHP模塊。
- ### For PHP 7.3
- $ yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
- ### For PHP 7.2
- $ yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
- ### For PHP 7.1
- $ yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
你可以運行以下命令,在已配置的yum存儲庫下搜索其他可用的PHP模塊。
下面的示例命令搜索PHP 7.3的所有模塊。
- $ yum --enablerepo=remi-php73 search php | grep php73
- php73.x86_64 : Package that installs PHP 7.3
- php73-php.x86_64 : PHP scripting language for creating dynamic web sites
- php73-php-bcmath.x86_64 : A module for PHP applications for using the bcmath
- php73-php-brotli.x86_64 : Brotli Extension for PHP
- php73-php-cli.x86_64 : Command-line interface for PHP
- php73-php-common.x86_64 : Common files for PHP
- ...
- ...
新聞熱點
疑難解答