1. Installation source
To install php72w, you need to configure an additional yum source address, otherwise an error will be reported and the relevant software package cannot be found.
The yum source address of the higher version of php has two parts, one part is epel-release, and the other part is from webtatic. If epel-release is skipped, an error will pop up when installing webtatic.
So, the command needed here is:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Of course, you can also choose the following command, which has the same effect.
yum install epel-release -y
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2. Clear historical versions
In order to prevent php conflicts on centos, it is better to execute this command first.
yum -y remove php*
3. Install the expansion pack
In fact, there are a lot of corresponding extension libraries. Here you must pay attention to the two packages of cli and fpm, and other related packages depend on your needs.
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel
There is also a more luxurious version:
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
4. After the installation is complete, start the service
systemctl enable php-fpm.service
systemctl start php-fpm.service
5. Check whether the installation is successful
# php -v
PHP 7.2.34 (cli) (built: Oct 1 2020 13:37:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies