方法一:
如果系统中已经安装了php,那就先卸载下
yum remove -y php*
1. CentOS7下初始yum源并没有php7.2,所以我们要更改yum源
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
2. yum 安装php72w和各种拓展,选自己需要的即可
yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mcrypt php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache php72w-pecl-memcached php72w-pecl-redis php72w-pecl-mongodb
方法二:
首先下载下载php的所有包及依赖包,再使用yum进行本地安装
文章结尾提供下我已经下载好的php72版本的整合包
1.解压php72版本的压缩包
tar -xf php72w.tar.gz
2.使用yum进行本地安装
yum -y localinstall php72w/{php72w,php72w-cli,php72w-common,php72w-devel,php72w-embedded,php72w-gd,php72w-mbstring,php72w-pdo,php72w-xml,php72w-fpm,php72w-mysqlnd,php72w-opcache,php72w-pecl-memcached,php72w-pecl-redis,php72w-pecl-mongodb}*.rpm
方法三:
1、配置安装yum源 EPEL and Remi repository
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
2、安装 yum-utils
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
3、 yum-config-manager 管理要安装的版本,以下3个,选择自己要安装的版本执行
yum-config-manager --enable remi-php72 [Install PHP 7.2,选择性安装]
yum-config-manager --enable remi-php70 [Install PHP 7.0,选择性安装]
yum-config-manager --enable remi-php71 [Install PHP 7.1,选择性安装]
4、开始安装
yum install php72-php-mcrypt php72-php-cli php72-php-gd php72-php-curl php72-php-mysqlnd php72-php-ldap php72-php-zip php72-php-fileinfo php72-php-fpm