How to Run PHP-FPM 8.0 and PHP-FPM 7.4 Simultaneously for Different Sites on Centos 7 Nginx

Running websites on different CMS or different versions of the same CMS, it is usual that some sites need PHP 7.4, others PHP 7.2 and others can work on PHP 8.0 and so on. Centos 7 now has several php-fpm packages, and this article describes how to run two or more php-fpm services and configure nginx to use certain php version for certain site.


1. Update to PHP 8 on Centos if you still did not

Check current php version

php -v
  PHP 7.4.30 (cli) (built: Jun  7 2022 08:38:19) ( NTS )

Install yum-utils if you still have not

yum install epel-release yum-utils

Check which php versions are mentioned in yum-config-manager

yum-config-manager | grep php


Check available versions of php:

yum search php-fpm

php-fpm.x86_64 : PHP FastCGI Process Manager
php54-php-fpm.x86_64 : PHP FastCGI Process Manager
php55-php-fpm.x86_64 : PHP FastCGI Process Manager
php56-php-fpm.x86_64 : PHP FastCGI Process Manager
php70-php-fpm.x86_64 : PHP FastCGI Process Manager
php71-php-fpm.x86_64 : PHP FastCGI Process Manager
php72-php-fpm.x86_64 : PHP FastCGI Process Manager
php73-php-fpm.x86_64 : PHP FastCGI Process Manager
php74-php-fpm.x86_64 : PHP FastCGI Process Manager
php80-php-fpm.x86_64 : PHP FastCGI Process Manager
php81-php-fpm.x86_64 : PHP FastCGI Process Manager
php82-php-fpm.x86_64 : PHP FastCGI Process Manager

There are actually many versions, but you should check which can be used from remi repository. I found it is remi-php80, because `yum-config-manager --enable remi-php82` added nothing and `yum-config-manager | grep php` result was not changed.

Add php80, update and check it is default:

yum-config-manager --enable remi-php80
yum update -y
php -v
  PHP 8.0.21 (cli) (built: Jul  6 2022 10:13:53) ( NTS gcc x86_64 )

Now the latest php80 is running as default.


2. Edit php-fpm.d/www.conf for old PHP 7.4 to listen another socket as PHP 8.0

You can find and configure socket that the default PHP 8.0 is listening:

grep -P '^listen = ' /etc/php-fpm.d/www.conf
listen =

Also "user" and "group" should be checked there, for me it is nginx.

Next, configure another socket, for example listen = in remi php74-php-fpm here (thanks to [3]):

vim /etc/opt/remi/php74/php-fpm.d/www.conf

user = nginx
group = nginx
listen =

So, these lines should be checked and configured.


3. Add php74-php-fpm service

Centos 7 works with systemctl, let's check our services

systemctl status php74-php-fpm 
...  disabled

Enable and start service of php 7.4, then check listening ports:

systemctl enable php74-php-fpm 
systemctl start php74-php-fpm 
netstat -tunlp
  tcp    0  0*   LISTEN  11419/php-fpm: mast 
  tcp    0  0*   LISTEN  11638/php-fpm: mast

Here, port 9000 is listening by default php80-php-fpm and port 9001 is listening by remi's php74-php-fpm. Now let's go to nginx configs.


4. Configure nginx to work with different php versions

Use hosts config files for that. On my server I defined php socket in /etc/nginx/fastcgi_params like this:

head -1 /etc/nginx/fastcgi_params

Sometimes variable fastcgi_pass is defined in host configuration files like this

grep fastcgi_pass /etc/nginx/sites-available/


But sometimes this variable can be set in /etc/nginx/fastcgi_params.

Please, read carefully /etc/nginx/nginx.conf and /etc/nginx/fastcgi_params and also configs of your sites (hosts) for fit certain php version. On my server that was like this. I copied fastcgi_params, changed port for another version, and included different fastcgi_params to hosts configs:

cp /etc/nginx/fastcgi_params /etc/nginx/fastcgi_params_php7

vim /etc/nginx/fastcgi_params_php7

vim /etc/nginx/sites-available/
include             /etc/nginx/fastcgi_params_php7;

vim /etc/nginx/sites-available/
include             /etc/nginx/fastcgi_params;

To sites are here: is using /etc/nginx/fastcgi_params

and is using /etc/nginx/fastcgi_params_php7


Next check configs and restart nginx:

nginx -t
service nginx restart


5. Check phpinfo(); on sites

Create php file with content

<?php phpinfo(); ?>

Place it to sites directories and visit it:
    PHP Version 7.4.30
PHP Version 8.0.21

That's it. is configured to forward request to php files to socket of php74: fastcgi_pass is configured to forward request to php files to socket of php80: fastcgi_pass



1. Update to php80-php-fpm on Centos 7…

2. Run multiple websites with different php versions in nginx…

3. Where are config files for remi php repositories?…