1,yum源默认的版本太低了,手动安装有一些麻烦,所以可以采用yum的方式进行安装。
2,检查当前安装的PHP包
yum list installed | grep php如果有安装的PHP包,先删除他们
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_643,更换rpm源
Centos 5.X:rpm -Uvh CentOs 6.x:rpm -Uvh CentOs 7.X:rpm -Uvh rpm -Uvh4,如果想删除上面安装的包
rpm -qa | grep webstaticrpm -e 上面搜索到的包即可5,下面使用yum进行安装
#安装php5.5yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_6#安装php5.6
yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64#安装php7.0
yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_646,安装php-fpm
yum install php55w-fpm yum install php56w-fpm yum install php70w-fpm
CentOS自带了PHP5,安装PHP7.2的时候会遇到一些冲突.
参考:https://blog.csdn.net/xieliang5210/article/details/87157892
首先获取rpm:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 12然后可以利用 sudo yum list php*查看目前都有php的什么版本了,可以发现从4-7.2的版本都有,7.2版本名为72w,因此安装该版本即可:sudo yum -y install php72w
1遇到问题:Transaction check error:
file /etc/httpd/conf.d/php.conf from install of mod_php72w-7.2.14-1.w7.x86_64 conflicts with file from package php-5.4.16-46.el7.x86_64 file /etc/httpd/conf.modules.d/10-php.conf from install of mod_php72w-7.2.14-1.w7.x86_64 conflicts with file from package php-5.4.16-46.el7.x86_64错误概要
-------------123456解决:yum -y remove php-5.4.16-46.el7.x86_64
1但安装完毕后,输入php -v发现并没有该命令,因为php72w只是安装了php最小的库,一些应用还未安装,因此安装一些拓展包即可:yum -y install php72w-cli php72w-common php72w-devel php72w-mysql
1遇到问题:错误:php72w-common conflicts with php-common-5.4.16-46.el7.x86_64
您可以尝试添加 --skip-broken 选项来解决该问题 您可以尝试执行:rpm -Va --nofiles --nodigest123解决:yum -y remove php-common-5.4.16-46.el7.x86_64
1然后输入php -v出现如下信息:PHP 7.2.14 (cli) (built: Jan 12 2019 12:47:33) ( NTS )
Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologie