1080*80 ad

Install PHP 5.6 to 8.4 with PHP-FPM and FastCGI on Ubuntu 22.04/24.04 for ISPConfig 3.2

How to Install Multiple PHP Versions (5.6 to 8.4) on Ubuntu 22.04 & 24.04 for ISPConfig

Managing a modern web server often means juggling the diverse requirements of different applications. While new projects thrive on the latest PHP versions, legacy websites may be locked into older, unsupported releases. This guide provides a comprehensive walkthrough for installing and managing multiple PHP versions, from 5.6 up to the latest 8.4, on a single Ubuntu 22.04 or 24.04 server running ISPConfig 3.2.

By following these steps, you can create a flexible hosting environment capable of serving a wide range of web applications, each with its specific PHP dependency.

Why You Need Multiple PHP Versions

Running different PHP versions simultaneously is essential for:

  • Hosting Legacy Applications: Many older websites or scripts are not compatible with modern PHP and require a specific version like PHP 5.6 or 7.4 to function correctly.
  • Supporting Multiple Clients: If you manage a server for various clients, you can offer them a choice of PHP versions, catering to their individual needs.
  • Testing and Development: Developers can easily switch between PHP versions to test application compatibility and prepare for future upgrades.

This tutorial leverages the widely trusted ondrej/php PPA, which provides well-maintained packages for various PHP releases on Ubuntu.

Prerequisites

Before you begin, ensure you have the following:

  • A running server with Ubuntu 22.04 LTS (Jammy Jellyfish) or Ubuntu 24.04 LTS (Noble Numbat).
  • Root or sudo access to the server.
  • A working ISPConfig 3.2 installation.

Step 1: Add the PHP PPA Repository

The first step is to add the PPA (Personal Package Archive) that contains all the necessary PHP packages. This repository is the standard for installing multiple PHP versions on Debian-based systems.

Open your terminal and execute the following commands to add the repository and update your package list:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

Step 2: Install the Required PHP Versions

With the repository in place, you can now install any PHP version you need. The key is to install both the PHP-FPM (FastCGI Process Manager) and CGI packages for each version to ensure full compatibility with ISPConfig.

You can install all common versions at once with a single command. This command also includes essential modules that most web applications, like WordPress or Magento, rely on.

sudo apt-get install -y php5.6-fpm php5.6-cgi php5.6-mysql php5.6-curl php5.6-gd php5.6-imagick php5.6-imap php5.6-intl php5.6-mbstring php5.6-xml php5.6-zip \
php7.4-fpm php7.4-cgi php7.4-mysql php7.4-curl php7.4-gd php7.4-imagick php7.4-imap php7.4-intl php7.4-mbstring php7.4-xml php7.4-zip \
php8.1-fpm php8.1-cgi php8.1-mysql php8.1-curl php8.1-gd php8.1-imagick php8.1-imap php8.1-intl php8.1-mbstring php8.1-xml php8.1-zip \
php8.2-fpm php8.2-cgi php8.2-mysql php8.2-curl php8.2-gd php8.2-imagick php8.2-imap php8.2-intl php8.2-mbstring php8.2-xml php8.2-zip \
php8.3-fpm php8.3-cgi php8.3-mysql php8.3-curl php8.3-gd php8.3-imagick php8.3-imap php8.3-intl php8.3-mbstring php8.3-xml php8.3-zip

Note: You can customize this command to install only the versions you require. For example, to install only PHP 8.3, you would run sudo apt-get install php8.3-fpm php8.3-cgi php8.3-mysql php8.3-common ... and include any other modules your applications need.

Step 3: Configure ISPConfig to Recognize New PHP Versions

After installing the packages, you need to inform ISPConfig where to find them. This is done by creating a custom configuration file.

Create and edit the following file using a text editor like nano:

sudo nano /usr/local/ispconfig/server/conf-custom/php_versions.conf

Paste the following configuration into the file. This snippet defines the paths for each PHP version you installed. Adjust it to match the versions you have on your system.

[php_versions]
php5.6=/usr/bin/php-cgi5.6:/etc/php/5.6/cgi/php.ini:/usr/sbin/php-fpm5.6:/etc/php/5.6/fpm/pool.d
php7.4=/usr/bin/php-cgi7.4:/etc/php/7.4/cgi/php.ini:/usr/sbin/php-fpm7.4:/etc/php/7.4/fpm/pool.d
php8.1=/usr/bin/php-cgi8.1:/etc/php/8.1/cgi/php.ini:/usr/sbin/php-fpm8.1:/etc/php/8.1/fpm/pool.d
php8.2=/usr/bin/php-cgi8.2:/etc/php/8.2/cgi/php.ini:/usr/sbin/php-fpm8.2:/etc/php/8.2/fpm/pool.d
php8.3=/usr/bin/php-cgi8.3:/etc/php/8.3/cgi/php.ini:/usr/sbin/php-fpm8.3:/etc/php/8.3/fpm/pool.d

Save the file and exit the editor (in nano, press CTRL+X, then Y, then Enter).

Step 4: Update ISPConfig Configuration

The final step is to run the ISPConfig updater. This process will re-scan your server’s configuration, detect the new php_versions.conf file, and integrate the new PHP versions into the control panel.

Run the update script with the following command:

sudo ispconfig_update.sh

Follow the on-screen prompts. It is safe to accept the default values for most options. The script will back up your existing configuration and then reconfigure services, including Apache/Nginx, to work with the newly available PHP handlers.

Verification and Usage

Once the update is complete, log in to your ISPConfig control panel. Navigate to the Sites tab and either edit an existing website or create a new one. In the PHP Version dropdown menu, you should now see all the PHP versions you installed and configured.

You can now assign a specific PHP version to each website on your server. PHP-FPM is the recommended handler for its superior performance and resource management.

Important Security Considerations

  • End-of-Life (EOL) PHP Versions: Be aware that older versions like PHP 5.6 and all 7.x releases are end-of-life. This means they no longer receive security updates from the official PHP developers.
  • Actionable Advice: Only use EOL versions for legacy applications that absolutely cannot be upgraded. Isolate these sites as much as possible and prioritize migrating them to a supported PHP version to avoid exposure to known vulnerabilities.
  • Stay Updated: Regularly run sudo apt-get update && sudo apt-get upgrade to ensure all your installed PHP packages receive the latest security patches provided by the PPA maintainer.

Source: https://www.howtoforge.com/ispconfig-php-ubuntu/

900*80 ad

      1080*80 ad