Installing PHP 5.6 and PHP-FPM on Debian 12

PHP 5.6 is an outdated release of PHP that reached end-of-life (EOL) on December 31, 2018. It no longer receives security patches and is therefore vulnerable to exploits. Still, certain legacy applications may depend on PHP 5.6 for compatibility.

Warning

Never use PHP 5.6 in production. It presents serious security vulnerabilities and should only be deployed in development or testing environments.

Prerequisites

Before you begin:

  • Ensure you have access to a Debian 12 Linux instance with a non-root user who has sudo privileges.

Add the PHP PPA Repository

Debian 12 does not ship with PHP 5.6 in its default repositories. You must add a third-party repository. Follow these steps to include the SURY PHP PPA repository.

Update the package index

Upgrade all existing packages

Install required dependencies for HTTPS transport and certificate management

$ sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https

Download the SURY GPG key

$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Add the SURY PPA repository information to your APT sources

$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Update the package index again to apply repository changes

Verify the added PPA

Example output:

php:
  Installed: (none)
  Candidate: 2:8.4+96+0~20250402.56+debian12~1.gbp84a5b7
...

Install PHP 5.6

Proceed with the following steps to install PHP 5.6 on your Debian 12 system.

Install PHP 5.6

$ sudo apt install php5.6 -y

Verify the PHP version

Example output:

PHP 5.6.40-81+0~20250311.98+debian12~1.gbp4564f4 (cli) 
...

Install common PHP 5.6 extensions

$ sudo apt install -y php5.6-common php5.6-mysql php5.6-xml php5.6-json php5.6-curl php5.6-gd php5.6-mbstring php5.6-zip

Install PHP 5.6 FPM

PHP-FPM (FastCGI Process Manager) enables PHP to work efficiently with web servers to handle dynamic content. Follow these steps to install PHP-FPM for PHP 5.6.

Install PHP 5.6 FPM

$ sudo apt install -y php5.6-fpm

Enable PHP-FPM service at boot

$ sudo systemctl enable php5.6-fpm

Start the PHP-FPM service

$ sudo systemctl start php5.6-fpm

Check PHP-FPM status

$ sudo systemctl status php5.6-fpm

Example output:

  ● php5.6-fpm.service - The PHP 5.6 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php5.6-fpm.service; enabled; preset: enabled)
     Active: active (running) since Sat 2025-04-12 03:58:28 UTC; 11s ago
...

Test and Use PHP 5.6

Before proceeding, confirm that PHP 5.6 is working correctly and that the required extensions are active.

Create an info.php file for testing

$ sudo nano /var/www/html/info.php

Add the following content to the file

The phpinfo() function displays details about your PHP setup and other system information.

Save and close the file.

Enable the PHP-FPM configuration for Apache

$ sudo a2enconf php5.6-fpm

Reload Apache to apply the new configuration

$ sudo systemctl reload apache2

Allow HTTP traffic through the firewall

Reload UFW to apply the changes

Now open the info.php file in your web browser and confirm that PHP information is displayed.

Example: http://app.example.com/info.php

Conclusion

You have successfully installed PHP 5.6 and PHP-FPM 5.6 on Debian 12. Your system can now process and serve PHP files. Remember that this PHP version is outdated and insecure. Use it only for legacy application testing, and for production environments upgrade to a supported PHP release such as PHP 8.3.

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: