Introduction
This tutorial will guide you through the process of installing PHP versions 5.6 and 7.0 through 8.3 with PHP-FPM and FastCGI mode for ISPConfig 3.2 on Debian 9 to 12. ISPConfig is an open-source hosting control panel for Linux which allows you to manage multiple servers from a single control panel.
Prerequisites
Before you begin, ensure you have:
- A Debian server running version 9 to 12
- SSH access to the server
- Root or sudo privileges
Step 1: Add PHP Repository
Add the ondrej/php repository which provides multiple PHP versions:
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Step 2: Install PHP Versions
Install the desired PHP versions along with PHP-FPM:
sudo apt install -y php5.6-fpm php7.0-fpm php7.1-fpm php7.2-fpm php7.3-fpm php7.4-fpm php8.0-fpm php8.1-fpm php8.2-fpm php8.3-fpm
Step 3: Configure PHP-FPM
Edit the PHP-FPM configuration file for each PHP version:
sudo nano /etc/php/5.6/fpm/pool.d/www.conf
sudo nano /etc/php/7.0/fpm/pool.d/www.conf
sudo nano /etc/php/7.1/fpm/pool.d/www.conf
sudo nano /etc/php/7.2/fpm/pool.d/www.conf
sudo nano /etc/php/7.3/fpm/pool.d/www.conf
sudo nano /etc/php/7.4/fpm/pool.d/www.conf
sudo nano /etc/php/8.0/fpm/pool.d/www.conf
sudo nano /etc/php/8.1/fpm/pool.d/www.conf
sudo nano /etc/php/8.2/fpm/pool.d/www.conf
sudo nano /etc/php/8.3/fpm/pool.d/www.conf
Modify the listen directive to use a socket instead of TCP:
listen = /run/php/php{version}-fpm.sock
Replace {version}
with the respective PHP version (e.g., 5.6, 7.0, etc.).
Save the file and exit the text editor.
Step 4: Restart PHP-FPM Services
Restart PHP-FPM services for each PHP version:
sudo systemctl restart php5.6-fpm
sudo systemctl restart php7.0-fpm
sudo systemctl restart php7.1-fpm
sudo systemctl restart php7.2-fpm
sudo systemctl restart php7.3-fpm
sudo systemctl restart php7.4-fpm
sudo systemctl restart php8.0-fpm
sudo systemctl restart php8.1-fpm
sudo systemctl restart php8.2-fpm
sudo systemctl restart php8.3-fpm
Step 5: Configure FastCGI for ISPConfig
Configure ISPConfig to use FastCGI and PHP-FPM for each PHP version:
sudo nano /etc/apache2/conf-available/ispconfig.conf
Add the following lines for each PHP version:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://unix:/run/php/php{version}-fpm.sock|fcgi://localhost/var/www/ispconfig/{domain}/web/$1
Replace {version}
with the respective PHP version (e.g., 5.6, 7.0, etc.).
Save the file and exit the text editor.
Enable the FastCGI configuration:
sudo a2enconf ispconfig
sudo systemctl restart apache2
Step 6: Verify PHP-FPM Configuration
Verify that PHP-FPM is running and listening on the specified sockets:
sudo systemctl status php{version}-fpm
Replace {version}
with the respective PHP version (e.g., 5.6, 7.0, etc.).
Conclusion
You have successfully installed PHP versions 5.6 and 7.0 through 8.3 with PHP-FPM and FastCGI mode for ISPConfig 3.2 on Debian 9 to 12. You can now configure virtual hosts in ISPConfig to use different PHP versions for your websites and web applications.