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:

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.

  1. Update the server’s package information index.

    console Copy

    $ sudo apt update -y
    
  2. Upgrade all existing packages.

    console Copy

    $ sudo apt upgrade -y
    
  3. 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
    
  4. Download the SURY GPG key.

    console Copy

    $ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
    
  5. 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
    
  6. Update the package index to apply the repository changes.

    console Copy

    $ sudo apt update -y
    
  7. 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.

  1. Install the PHP 5.6 version.

    console Copy

    $ sudo apt install php5.6 -y
    
  2. Verify the PHP version.

    console Copy

    $ php5.6 -v
    

    Output:

    PHP 5.6.40-81+0~20250311.98+debian12~1.gbp4564f4 (cli)
    ...
    
  3. 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.

  1. Install PHP 5.6 FPM.

    console Copy

    $ sudo apt install -y php5.6-fpm
    
  2. Enable the PHP-FPM service to start at boot automatically.

    console Copy

    $ sudo systemctl enable php5.6-fpm
    
  3. Start the PHP-FPM service.

    console Copy

    $ sudo systemctl start php5.6-fpm
    
  4. 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.

  1. Create info.php file for testing purposes.

    console Copy

    $ sudo nano /var/www/html/info.php
    
  2. 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.

  3. Enable the PHP-FPM configuration for Apache.

    console Copy

    $ sudo a2enconf php5.6-fpm
    
  4. Reload the Apache to apply the new configuration.

    console Copy

    $ sudo systemctl reload apache2
    
  5. Allow the HTTP traffic through the firewall.

    console Copy

    $ sudo ufw allow http
    
  6. Reload UFW to apply the new changes.

    console Copy

    $ sudo ufw reload
    
  7. 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.


Last update: Jun 30, 2025