一、首先查看是否有老版本
yum list installed | grep 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_64
三、老版本清理干净之后,进行升级
1、安装epel-release
rpm -ivh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-9.noarch.rpm
(这个大家可以访问https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/目录,下载epel-release-xxx.noarch.rpm的最新版本)
成功安装。
2、安装PHP7
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
成功获取PHP7的yum源,然后再执行:
yum install -y php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-ldap php72w-mcrypt
php 7.0/7.1/7.2 分别表示为 70w/71w/72w
四、如果报错不要紧张,执行清除操作
yum clean all
五、最后重新执行安装
yum install -y php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-ldap php72w-mcrypt