How to run multiple PHP versions with apache on CentOS 7 linux - Tuxtips.net
<aside> 💡 Notes:
</aside>
In today tutorial, we want to show how to run multiple PHP versions with apache on CentOS 7 linux.
it’s very practical and common to have multiple php versions and run it simultaneously with apache on a single server.
maybe you have a php script and want to test it with multiple php version. in such case this article is for you.
Lets explain how it’s possible to run multiple versions.
when we request a .php page from apache, it will refer to “SetHandler application/x-httpd-php” to know which module should be loaded to handle php script. the point is that here, php is under apache control.in our scenario, things go different. here we use standalone php process called php-fpm. php-fpm is a php daemon that is configured to respond to FCGI requests.so we start and stop php-fpm and apache independently.
Here is our environment:
OS: CentOS 7 linux on VMWareFirewall: enabledSELinux: enforcingPHP versions: 5.6 and 7.2
before installing and running two php versions, we need to install apache and some repository. so execute these commands:
yum install httpd
yum install epel-release
yum install yum-utils
php-fpm is available in remi repository. so we install this repo and then after multiple php versions:
yum install <http://rpms.remirepo.net/enterprise/remi-release-7.rpm>
yum install php56
yum install php72
yum install php56-php-fpm
yum install php72-php-fpm
then make sure both versions are stopped:
systemctl stop php56-php-fpm
systemctl stop php72-php-fpm