In this tutorial we will set up multiple PHP Versions which is 5.6 & 7.2 on the Apache same machine.

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.

 

1- Install prerequisites

before installing and running two php versions, we need to install apache and some repository. so execute these commands:

2- Install multiple php versions

php-fpm is available in remi repository. so we install this repo and then after multiple php versions:

3- Configure SELinux

Install Selinux Policy Targeted

to allow selinux run php-fpms scripts, run these commands:

4- Configure php-fpm

by default, each php-fpm version is listening on port 9000. because we want to run multiple php versions, we need to change default port:

Start the php-fpm

now we need to make script wrapper to call php56-cgi and php72-cgi:

Then we set executable bit on both scripts:

5- Configure apache

Here we create two path. one for php-fpm56 and another for php-fpm72. you can change these paths with your own:

Php7.2 /var/www/html

Php5.6 /var/www/html56

Edit conf file /etc/httpd/conf.d/php.conf

gt;
SetHandler “proxy:fcgi://127.0.0.1:9072”
</FilesMatch>
# Some legacy application use PHP 5.5
<Directory /var/www/html56>
<FilesMatch \.php

gt;
SetHandler “proxy:fcgi://127.0.0.1:9056”
</FilesMatch>
</Directory>

6- Start services

Now we enable and start apache and php-fpm services:

7- Check for result

 

Good luck! All Done

0
Would love your thoughts, please comment.x
()
x