Unlock unparalleled flexibility and power on your Ubuntu self-hosted server! This comprehensive guide empowers you to seamlessly install and manage a wide array of PHP versions, from the foundational 5.6 to the bleeding-edge 8.4, all integrated perfectly within your ISPConfig control panel. For developers and administrators handling diverse web projects, mastering PHP version control is paramount for ensuring optimal compatibility, performance, and security across all applications. Dive in to transform your web server management experience and gain granular control over your self-hosting environment.
Mastering Multi-PHP: Install PHP Versions on Ubuntu with ISPConfig
Managing a robust self-hosting environment often requires flexibility, especially when dealing with various web applications built on different PHP versions. By default, ISPConfig on Ubuntu offers a single, distribution-specific PHP version. This guide provides a detailed, step-by-step walkthrough to install and configure multiple PHP versions (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, and 8.4) on your Ubuntu server, seamlessly integrating them with ISPConfig. These instructions are validated for Ubuntu 22.04 and 24.04, and remain largely applicable for Ubuntu 20.04. Once configured, you’ll be able to select specific PHP versions for individual websites in PHP-FPM and FastCGI modes, compatible with both Apache and Nginx web servers.
1. Understanding the SURY Repository & Key Considerations
To access such a wide range of PHP versions, we’ll leverage the trusted SURY repository, maintained by Ondřej Surý. This repository provides up-to-date PHP packages and various extensions. However, it’s crucial to understand a key aspect:
Important Note: The SURY repository updates core system packages like OpenSSL alongside PHP. Therefore, once added, you should not remove SURY as a repository source later, as this could lead to system instability or broken dependencies. This commitment ensures your system remains consistent with the packages provided by SURY.
Also, remember that PHP-FPM offers superior performance and process management for both Apache and Nginx, while FastCGI is primarily an option for Apache servers.
2. Seamless Integration: Adding the SURY PHP Repository
The first step to unlocking multiple PHP versions is adding the SURY repository to your system’s package sources. This ensures you can access all the necessary PHP packages.
Add the repository:
add-apt-repository -y ppa:ondrej/phpNow, update your package list to recognize the new repository:
apt-get updateTo upgrade any already installed packages to their versions from the new repository (including potential PHP updates for your default version or other system libraries), use this command:
apt-get upgrade3. Installing Diverse PHP Versions for Ultimate Flexibility
You don’t need to install every single version listed here. Choose only the PHP versions your projects require. Each command includes common extensions vital for most web applications. For older versions like PHP 5.6, ensure you install libicu65, as it’s a specific dependency not always pulled automatically.
3.1. Install PHP 5.6 (for Legacy Applications)
apt-get install php5.6 php5.6-cli php5.6-cgi php5.6-fpm php5.6-gd php5.6-mysql php5.6-imap php5.6-curl php5.6-intl php5.6-pspell php5.6-recode php5.6-sqlite3 php5.6-tidy php5.6-xmlrpc php5.6-xsl php5.6-zip php5.6-mbstring php5.6-soap php5.6-opcache libicu65 php5.6-common php5.6-json php5.6-readline php5.6-xml3.2. Install PHP 7.0
apt-get install php7.0 php7.0-cli php7.0-cgi php7.0-fpm php7.0-gd php7.0-mysql php7.0-imap php7.0-curl php7.0-intl php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-zip php7.0-mbstring php7.0-soap php7.0-opcache php7.0-common php7.0-json php7.0-readline php7.0-xml3.3. Install PHP 7.1
apt-get install php7.1 php7.1-cli php7.1-cgi php7.1-fpm php7.1-gd php7.1-mysql php7.1-imap php7.1-curl php7.1-intl php7.1-pspell php7.1-recode php7.1-sqlite3 php7.1-tidy php7.1-xmlrpc php7.1-xsl php7.1-zip php7.1-mbstring php7.1-soap php7.1-opcache php7.1-common php7.1-json php7.1-readline php7.1-xml3.4. Install PHP 7.2
apt-get install php7.2 php7.2-cli php7.2-cgi php7.2-fpm php7.2-gd php7.2-mysql php7.2-imap php7.2-curl php7.2-intl php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-zip php7.2-mbstring php7.2-soap php7.2-opcache php7.2-common php7.2-json php7.2-readline php7.2-xml3.5. Install PHP 7.3
apt-get install php7.3 php7.3-cli php7.3-cgi php7.3-fpm php7.3-gd php7.3-mysql php7.3-imap php7.3-curl php7.3-intl php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl php7.3-zip php7.3-mbstring php7.3-soap php7.3-opcache php7.3-common php7.3-json php7.3-readline php7.3-xml3.6. Install PHP 7.4
apt-get install php7.4 php7.4-cli php7.4-cgi php7.4-fpm php7.4-gd php7.4-mysql php7.4-imap php7.4-curl php7.4-intl php7.4-pspell php7.4-sqlite3 php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-zip php7.4-mbstring php7.4-soap php7.4-opcache php7.4-common php7.4-json php7.4-readline php7.4-xml3.7. Install PHP 8.0
apt-get install php8.0 php8.0-cli php8.0-cgi php8.0-fpm php8.0-gd php8.0-mysql php8.0-imap php8.0-curl php8.0-intl php8.0-pspell php8.0-sqlite3 php8.0-tidy php8.0-xsl php8.0-zip php8.0-mbstring php8.0-soap php8.0-opcache php8.0-common php8.0-readline php8.0-xml3.8. Install PHP 8.1
apt-get install php8.1 php8.1-cli php8.1-cgi php8.1-fpm php8.1-gd php8.1-mysql php8.1-imap php8.1-curl php8.1-intl php8.1-pspell php8.1-sqlite3 php8.1-tidy php8.1-xsl php8.1-zip php8.1-mbstring php8.1-soap php8.1-opcache php8.1-common php8.1-readline php8.1-xml3.9. Install PHP 8.2
apt-get install php8.2 php8.2-cli php8.2-cgi php8.2-fpm php8.2-gd php8.2-mysql php8.2-imap php8.2-curl php8.2-intl php8.2-pspell php8.2-sqlite3 php8.2-tidy php8.2-xsl php8.2-zip php8.2-mbstring php8.2-soap php8.2-opcache php8.2-common php8.2-readline php8.2-xml3.10. Install PHP 8.3
apt-get install php8.3 php8.3-cli php8.3-cgi php8.3-fpm php8.3-gd php8.3-mysql php8.3-imap php8.3-curl php8.3-intl php8.3-pspell php8.3-sqlite3 php8.3-tidy php8.3-xsl php8.3-zip php8.3-mbstring php8.3-soap php8.3-opcache php8.3-common php8.3-readline php8.3-xml3.11. Install PHP 8.4
apt-get install php8.4 php8.4-cli php8.4-cgi php8.4-fpm php8.4-gd php8.4-mysql php8.4-imap php8.4-curl php8.4-intl php8.4-pspell php8.4-sqlite3 php8.4-tidy php8.4-xsl php8.4-zip php8.4-mbstring php8.4-soap php8.4-opcache php8.4-common php8.4-readline php8.4-xml4. Maintaining System Stability: Resetting Default PHP
After installing multiple PHP versions, your system’s default PHP CLI (Command Line Interface) and FPM (FastCGI Process Manager) might have shifted to the highest installed version. It’s crucial to revert these to your OS distribution’s native default to prevent conflicts with system-level packages and ISPConfig itself. Run these commands sequentially:
update-alternatives --config php
update-alternatives --config php-cgi
update-alternatives --config php-fpm.sockDuring these interactive prompts, select the option corresponding to your Ubuntu version’s default PHP:
- For Ubuntu 20.04, choose PHP 7.4.
- For Ubuntu 22.04, choose PHP 8.1.
- For Ubuntu 24.04, choose PHP 8.3.
Unique Tip: Always verify your system’s default PHP CLI version after making changes by running php -v. This quick check helps catch potential conflicts early, especially if you have cron jobs that rely on a specific default PHP version.
5. Empowering ISPConfig: Integrating New PHP Versions
Now that the PHP versions are installed, you need to tell ISPConfig where to find them. Navigate to System > Additional PHP Versions > Add new PHP version in your ISPConfig 3 panel.
5.1. Adding the Distribution’s Default PHP Version
Before adding the newly installed versions, ensure your distribution’s default PHP version is also configured in ISPConfig. This is vital for consistent ISPConfig PHP management. The default version varies by Ubuntu release:
- Ubuntu 20.04: PHP 7.4
- Ubuntu 22.04: PHP 8.1
- Ubuntu 24.04: PHP 8.3
Use the corresponding paths from the sections below for your distribution’s default PHP.
5.2. Configuration for Additional PHP Versions
For each PHP version you installed, create a new entry in ISPConfig using the following path configurations:
PHP 5.6
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi5.6 - Path to the php.ini directory:
/etc/php/5.6/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php5.6-fpm - Path to the php.ini directory:
/etc/php/5.6/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/5.6/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php5.6
- Path to the PHP CLI binary:
- PHP Jailkit section:
php5_6
PHP 7.0
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi7.0 - Path to the php.ini directory:
/etc/php/7.0/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php7.0-fpm - Path to the php.ini directory:
/etc/php/7.0/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/7.0/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php7.0
- Path to the PHP CLI binary:
- PHP Jailkit section:
php7_0
PHP 7.1
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi7.1 - Path to the php.ini directory:
/etc/php/7.1/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php7.1-fpm - Path to the php.ini directory:
/etc/php/7.1/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/7.1/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php7.1
- Path to the PHP CLI binary:
- PHP Jailkit section:
php7_1
PHP 7.2
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi7.2 - Path to the php.ini directory:
/etc/php/7.2/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php7.2-fpm - Path to the php.ini directory:
/etc/php/7.2/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/7.2/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php7.2
- Path to the PHP CLI binary:
- PHP Jailkit section:
php7_2
PHP 7.3
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi7.3 - Path to the php.ini directory:
/etc/php/7.3/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php7.3-fpm - Path to the php.ini directory:
/etc/php/7.3/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/7.3/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php7.3
- Path to the PHP CLI binary:
- PHP Jailkit section:
php7_3
PHP 7.4
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi7.4 - Path to the php.ini directory:
/etc/php/7.4/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php7.4-fpm - Path to the php.ini directory:
/etc/php/7.4/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/7.4/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php7.4
- Path to the PHP CLI binary:
- PHP Jailkit section:
php7_4
PHP 8.0
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi8.0 - Path to the php.ini directory:
/etc/php/8.0/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php8.0-fpm - Path to the php.ini directory:
/etc/php/8.0/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/8.0/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php8.0
- Path to the PHP CLI binary:
- PHP Jailkit section:
php8_0
PHP 8.1
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi8.1 - Path to the php.ini directory:
/etc/php/8.1/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php8.1-fpm - Path to the php.ini directory:
/etc/php/8.1/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/8.1/fpm/pool.d/
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php8.1
- Path to the PHP CLI binary:
- PHP Jailkit section:
php8_1
PHP 8.2
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi8.2 - Path to the php.ini directory:
/etc/php/8.2/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php8.2-fpm - Path to the php.ini directory:
/etc/php/8.2/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/8.2/fpm/pool.d
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php8.2
- Path to the PHP CLI binary:
- PHP Jailkit section:
php8_2
PHP 8.3
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi8.3 - Path to the php.ini directory:
/etc/php/8.3/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php8.3-fpm - Path to the php.ini directory:
/etc/php/8.3/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/8.3/fpm/pool.d
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php8.3
- Path to the PHP CLI binary:
- PHP Jailkit section:
php8_3
PHP 8.4
- Fast-CGI settings:
- Path to the PHP FastCGI binary:
/usr/bin/php-cgi8.4 - Path to the php.ini directory:
/etc/php/8.4/cgi/
- Path to the PHP FastCGI binary:
- PHP-FPM settings:
- Path to the PHP-FPM init script:
php8.4-fpm - Path to the php.ini directory:
/etc/php/8.4/fpm/ - Path to the PHP-FPM pool directory:
/etc/php/8.4/fpm/pool.d
- Path to the PHP-FPM init script:
- PHP-CLI settings:
- Path to the PHP CLI binary:
/usr/bin/php8.4
- Path to the PHP CLI binary:
- PHP Jailkit section:
php8_4
6. Conclusion: Master Your Multi-PHP Environment
Congratulations! You have successfully configured your Ubuntu server with ISPConfig to support a wide range of PHP versions. You can now easily select the ideal PHP version for each of your websites, enhancing compatibility and performance. Remember, it is strongly advised against changing your operating system’s default PHP version, as critical system components and ISPConfig itself rely on this for stable operation. For further assistance or discussions, feel free to engage with the vibrant ISPConfig community forums.
FAQ
- Question 1: Why is it necessary to install multiple PHP versions on a self-hosted server?
- Answer 1: Installing multiple PHP versions is crucial for self hosting environments that run diverse web applications. Older applications or frameworks might require specific, often outdated, PHP versions for compatibility, while modern projects benefit significantly from the performance, security, and feature enhancements of the latest PHP releases. This flexibility allows you to host a mixed portfolio of websites without compatibility issues or compromising on performance for new developments.
- Question 2: Is the SURY repository safe and reliable for server use?
- Answer 2: Yes, the SURY repository, maintained by Ondřej Surý, is widely recognized and trusted within the Linux community as a reliable source for PHP packages on Debian/Ubuntu systems. It provides up-to-date versions and essential extensions that are often not available in the distribution’s default repositories. However, as noted in the guide, because it also updates core system libraries, it should be considered a permanent addition to your system’s sources to maintain stability.
- Question 3: What are the main benefits of using PHP-FPM over FastCGI with ISPConfig?
- Answer 3: PHP-FPM (FastCGI Process Manager) is generally preferred over traditional FastCGI for several reasons, especially in modern web server management setups. PHP-FPM offers superior performance due to its optimized process management, allowing for better resource utilization and handling of concurrent requests. It provides advanced features like adaptive process spawning, status monitoring, and granular configuration for individual PHP pools, which translates to improved stability and scalability for your web applications. While FastCGI is simpler, PHP-FPM offers a more robust and efficient solution for high-traffic or complex environments, compatible with both Apache and Nginx.

