Install multiple versions of PHP with php-fpm

In this article, you will know how to install multiple versions of PHP in CentOS server.

Preparation

Firstly, run the following commands to use remi:

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

PHP 7.1

Installation

sudo yum-config-manager --enable remi-php71
sudo yum -y install php php-common php-fpm php-mysql php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo php-opcache

Configuring PHP-FPM

sudo nano /etc/php-fpm.d/www.conf

Changes the following configuration as below:

user = nginx
group = nginx
listen = 127.0.0.1:9000

Running as service:

sudo systemctl enable php-fpm
sudo systemctl start php-fpm
sudo systemctl status php-fpm
sudo systemctl restart php-fpm

PHP 5.6

Installation

sudo yum -y install php56 php56-php-common php56-php-fpm php56-php-mysql php56-php-pecl-memcache php56-php-pecl-memcached php56-php-gd php56-php-mbstring php56-php-mcrypt php56-php-xml php56-php-pecl-apc php56-php-cli php56-php-pear php56-php-pdo php56-php-opcache

Configuring PHP-FPM

sudo nano /opt/remi/php56/root/etc/php-fpm.d/www.conf

Changes the following configuration as below:

user = nginx
group = nginx
listen = 127.0.0.1:9001

Running as service:

sudo systemctl enable php56-php-fpm
sudo systemctl start php56-php-fpm
sudo systemctl status php56-php-fpm
sudo systemctl restart php56-php-fpm
Share this
Send this to a friend