
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.
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$ sudo apt update -y
Upgrade all existing packages.
console$ sudo apt upgrade -y
Install the required dependency packages for HTTPS transport and certificate management.
console$ sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
Download the SURY GPG key.
console$ 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$ 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$ sudo apt update -y
Verify the added PPA.
console$ 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$ sudo apt install php5.6 -y
Verify the PHP version.
console$ php5.6 -v
Output:
PHP 5.6.40-81+0~20250311.98+debian12~1.gbp4564f4 (cli) ...
Install the common PHP 5.6 extensions.
console$ 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$ sudo apt install -y php5.6-fpm
Enable the PHP-FPM service to start at boot automatically.
console$ sudo systemctl enable php5.6-fpm
Start the PHP-FPM service.
console$ sudo systemctl start php5.6-fpm
Verify the PHP-FPM service status and verify that it's running.
console$ 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$ sudo nano /var/www/html/info.php
Add the following content to this file.
php<?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$ sudo a2enconf php5.6-fpm
Reload the Apache to apply the new configuration.
console$ sudo systemctl reload apache2
Allow the HTTP traffic through the firewall.
console$ sudo ufw allow http
Reload UFW to apply the new changes.
console$ 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.
No comments yet.