Install PHP7 on CentOS7

References related to this article

EPEL Remi

Install EPEL software source and Remi software source

            yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
        

Use the tool to specify the installed version of PHP

We need to install the yum-utils tool to specify the default installed version of PHP. We can specify any version of PHP by modifying the version number. In the following example, we specify the version of PHP7.3.

            yum -y install yum-utils
yum-config-manager --enable remi-php73
        

Perform installation

After the above operations, our current default installation version of PHP has been designated as 7.3, and all PHP extensions are also designated as extensions of version 7.3. Next, we only need to execute the usual commands to install. The default version of 5.4 will not be installed during installation, but the 7.3 version we specified will be installed. If we want to change back to PHP5.4 version, we can also change to remi-php54 by reassigning the version number. Before installing the new version, we must uninstall the installed PHP and all its dependencies and extensions, otherwise the installation will fail.

            yum -y install php
yum -y install php-mysql