How to run multiple PHP versions on one server using Nginx and PHP-fpm on CentOs 7

1. Install Necessary Software:

Make sure you have Nginx and PHP installed on your CentOS server.

2. Install Additional PHP Versions:

You can use a repository like Remi to install multiple PHP versions. Install the repository and the desired PHP versions.

3. Configure PHP-FPM Pools:

For each PHP version, create a separate PHP-FPM pool configuration. The pool configuration files are typically located in /etc/php-fpm.d/. Create a new file for each PHP version, like php74-fpm.conf, and configure the necessary settings.

Sample php74-fpm.conf:

Repeat this step for each PHP version you have installed.

4. Configure Nginx to Use Multiple PHP Versions:

Edit your Nginx server block configuration to include different PHP-FPM sockets for each PHP version.

Sample Nginx configuration:

5. Restart Services:

Restart PHP-FPM and Nginx to apply the changes.

6. Test Configuration:

Create a simple PHP file (info.php) in your web root with the following content:

Access this file in your browser (http://yourdomain.com/info.php) to see the PHP version information.

Repeat these steps for each PHP version you want to run on your server. Adjust configurations based on your specific needs and security requirements.


Posted

in

, ,

by