How to Install PHP 5.6 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.

  1. Update the server’s package information index.
    console
    $ sudo apt update -y
    
  2. Upgrade all existing packages.
    console
    $ sudo apt upgrade -y
    
  3. 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
    
  4. Download the SURY GPG key.
    console
    $ 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
    $ 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
    $ sudo apt update -y
    
  7. 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.

  1. Install the PHP 5.6 version.
    console
    $ sudo apt install php5.6 -y
    
  2. Verify the PHP version.
    console
    $ 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
    $ 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
    $ sudo apt install -y php5.6-fpm
    
  2. Enable the PHP-FPM service to start at boot automatically.
    console
    $ sudo systemctl enable php5.6-fpm
    
  3. Start the PHP-FPM service.
    console
    $ sudo systemctl start php5.6-fpm
    
  4. 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.

  1. Create info.php file for testing purposes.
    console
    $ sudo nano /var/www/html/info.php
    
  2. 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.

  3. Enable the PHP-FPM configuration for Apache.
    console
    $ sudo a2enconf php5.6-fpm
    
  4. Reload the Apache to apply the new configuration.
    console
    $ sudo systemctl reload apache2
    
  5. Allow the HTTP traffic through the firewall.
    console
    $ sudo ufw allow http
    
  6. Reload UFW to apply the new changes.
    console
    $ 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.

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…

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…

Leave a Reply

Your email address will not be published. Required fields are marked *