How to Install PHP 5.6 on Debian 12¶
source https://docs.vultr.com/how-to-install-php-5-6-on-debian-12
Learn how to safely install and configure PHP 5.6 on Debian 12 for legacy application compatibility and testing purposes.
PHP 5.6 is a legacy version of PHP that reached its end-of-life (EOL) on December 31, 2018. It no longer receives security updates, making it vulnerable to exploits. However, some older applications may still require PHP 5.6 for compatibility.
This article explains how to install PHP 5.6 and PHP-FPM on Debian 12.
Warning
Do not use PHP 5.6 in production. It poses significant security risks and should only be used for development or testing.
Prerequisites¶
Before you begin:
Have access to a Debian 12 based Linux instance as a non-root sudo user.
Add the PHP PPA Repository¶
Debian 12 does not include PHP 5.6 in its default repositories, you must add a third-party repository. Follow the steps below to add the SURY PHP PPA repository.
Update the server’s package information index.
console Copy
$ sudo apt update -y
Upgrade all existing packages.
console Copy
$ sudo apt upgrade -y
Install the required dependency packages for HTTPS transport and certificate management.
console Copy
$ sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
Download the SURY GPG key.
console Copy
$ 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 source file.
console Copy
$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
Update the package index to apply the repository changes.
console Copy
$ sudo apt update -y
Verify the added PPA.
console Copy
$ sudo apt policy php
Output:
php: Installed: (none) Candidate: 2:8.4+96+0~20250402.56+debian12~1.gbp84a5b7 ...
Install PHP 5.6¶
Follow the steps below to install PHP 5.6 on your server.
Install the PHP 5.6 version.
console Copy
$ sudo apt install php5.6 -y
Verify the PHP version.
console Copy
$ php5.6 -v
Output:
PHP 5.6.40-81+0~20250311.98+debian12~1.gbp4564f4 (cli) ...
Install the common PHP 5.6 extensions.
console Copy
$ 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) helps PHP work with web servers to manage dynamic content efficiently. Follow the steps below to install PHP-FPM based on the PHP version on your server.
Install PHP 5.6 FPM.
console Copy
$ sudo apt install -y php5.6-fpm
Enable the PHP-FPM service to start at boot automatically.
console Copy
$ sudo systemctl enable php5.6-fpm
Start the PHP-FPM service.
console Copy
$ sudo systemctl start php5.6-fpm
Verify the PHP-FPM service status and verify that it’s running.
console Copy
$ sudo systemctl status php5.6-fpm
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, verify that PHP 5.6 is functioning. Testing helps confirm that the installation works as expected and that the necessary extensions are loaded.
Create
info.php
file for testing purposes.console Copy
$ sudo nano /var/www/html/info.php
Add the following content to this file.
php Copy
<?php phpinfo(); ?>
The
phpinfo()
function displays information about your PHP environment and other system details.Save and exit the file.
Enable the PHP-FPM configuration for Apache.
console Copy
$ sudo a2enconf php5.6-fpm
Reload the Apache to apply the new configuration.
console Copy
$ sudo systemctl reload apache2
Allow the HTTP traffic through the firewall.
console Copy
$ sudo ufw allow http
Reload UFW to apply the new changes.
console Copy
$ sudo ufw reload
Access the
info.php
file from your web browser and verify that your PHP information displays.http://app.example.com/info.php
Conclusion¶
You now have PHP 5.6 and PHP-FPM 5.6 installed on your Debian 12 instance. As tested, your instance can now process and serve PHP files. This version of PHP is obsolete and insecure. Use it only for legacy application testing. For production environments, upgrade to a supported version of PHP 8.3.