Tutorials  /  Ubuntu

How to Install PHP 5.6 on Ubuntu 24.04 with Apache and PHP-FPM

Ccentron Redaktion · August 2025 ·6 min read ·Ubuntu, Tutorial

PHP (Hypertext Preprocessor) is an open-source server-side scripting language widely used for web development. It enables developers to build dynamic websites, process form data, manage sessions, and integrate with databases like MySQL and PostgreSQL. PHP is highly extensible and supports multiple extensions you can use to build modern web applications.

This article explains how to install PHP 5.6 on Ubuntu 24.04. While PHP 5.6 has reached end-of-life, multiple applications still depend on it. You will install PHP 5.6 and configure PHP-FPM to integrate it with applications such as web servers.

Prerequisites

Before you begin, you need to:

  • Have access to an Ubuntu 24.04 instance as a non-root user with sudo privileges.
  • Create a domain A record pointing to your instance's public IP address.
VM

Matching infrastructure at centron

Ubuntu servers without your own hardware: ccloud³ VMs with full root access from €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Add the PHP PPA Repository

PHP 5.6 reached its end of life (EOL), and it's not available in the official Ubuntu repositories by default. However, you can still install it through the Ondřej Surý Personal Package Archive (PPA) source.

Add PHP PPA to the APT package repository sources.

Console
$ sudo add-apt-repository ppa:ondrej/php

Update the APT package index.

Console
$ sudo apt update

Install PHP 5.6

Follow the steps below to install PHP 5.6 and all necessary dependencies.

Install PHP 5.6, along with the command-line interface (CLI) and common PHP modules.

Console
$ sudo apt install php5.6 php5.6-cli php5.6-common -y

Verify the installed PHP version.

Console
$ php -v

Your output should be similar to the one below.

PHP 5.6.40-81+ubuntu24.04.1+deb.sury.org+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Note: If multiple PHP versions are installed on your workstation, use sudo update-alternatives --config php to set PHP 5.6 as the default version.

Install PHP 5.6 FPM

PHP-FPM (FastCGI Process Manager) handles PHP script execution efficiently when integrating it with web servers like Apache or Nginx. PHP-FPM is a process manager that runs PHP as a separate background service, handling requests independently from the web server, resulting in improved performance. Follow the steps below to install PHP 5.6 FPM to use it with other applications like web servers.

Install PHP-FPM for PHP 5.6.

Console
$ sudo apt install php5.6-fpm -y

Start the PHP-FPM service.

Console
$ sudo systemctl start php5.6-fpm

Enable the PHP-FPM service to automatically start at boot.

Console
$ sudo systemctl enable php5.6-fpm

View the PHP-FPM service status and verify that it's running.

Console
$ sudo systemctl status php5.6-fpm

Your output should be similar to the one below.

● php5.6-fpm.service - The PHP 5.6 FastCGI Process Manager
 Loaded: loaded (/usr/lib/systemd/system/php5.6-fpm.service; enabled; preset: enabled)
 Active: active (running) since Thu 2025-03-20 12:35:08 UTC; 33min ago
   Docs: man:php-fpm5.6(8)
Main PID: 47045 (php-fpm5.6)
 Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
  Tasks: 3 (limit: 2265)
 Memory: 10.2M (peak: 11.4M)
    CPU: 260ms
 CGroup: /system.slice/php5.6-fpm.service
         ├─47045 "php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)"
         ├─47047 "php-fpm: pool www"
         └─47048 "php-fpm: pool www"

Test and Use PHP 5.6

You can use PHP in different environments, such as the command line, interactive shells, and web server applications. Follow the steps below to test and verify the PHP installation on your server.

Create a new test.php file in your web root directory, such as /var/www/html.

Console
$ sudo nano /var/www/html/test.php

Add the following PHP code to the file.

Code
<!--?php echo "Greetings from centron! \n"; ?-->

Save and close the file.

Execute the PHP script.

Console
$ php /var/www/html/test.php

Output:

Greetings from centron!

Test PHP 5.6 with a Web Server

Follow the steps below to run PHP 5.6 with a web server such as Apache.

Create a new phpinfo.php file in your web root directory, such as /var/www/html.

Console
$ sudo nano /var/www/html/phpinfo.php

Add the following PHP code to the file.

Code
<!--?php phpinfo(); ?-->

Save and close the file.

Enable the proxy_fcgi module for Apache to communicate with PHP-FPM and the setenvif module to manage environment variables.

Console
$ sudo a2enmod proxy_fcgi setenvif

Restart the Apache service to apply the module changes.

Console
$ sudo systemctl restart apache2

Open the 000-default.conf Apache virtual host configuration.

Console
$ sudo nano /etc/apache2/sites-available/000-default.conf

Add the following configuration block within the <VirtualHost *:80> section to enable Apache to process PHP requests using the PHP 5.6 FPM socket.

Code
<FilesMatch \.php$>
    SetHandler "proxy:unix:/var/run/php/php5.6-fpm.sock|fcgi://localhost/"
</FilesMatch>

Save and close the file.

Test the Apache configuration for syntax errors.

Console
$ sudo apache2ctl -t

Output:

...
Syntax OK

Restart the Apache web server to apply the changes.

Console
$ sudo systemctl restart apache2

Allow HTTP connections through the firewall.

Console
$ sudo ufw allow 80

Reload the firewall configuration.

Console
$ sudo ufw reload

Access the /phpinfo.php path using your server's IP address in a web browser such as Chrome.

http://app.example.com/phpinfo.php

Verify that your PHP 5.6 information displays in the web browser and all installed extensions.

PHP 5.6 Information

Warning

PHP 5.6 reached its End of Life (EOL), meaning it no longer receives security patches, updates, or support. Running PHP 5.6 could expose your server to security vulnerabilities and compatibility issues. Only use outdated PHP versions on legacy systems that require them for specific applications.

Conclusion

You have installed PHP 5.6 on Ubuntu 24.04 and configured it to run with PHP-FPM. You can execute PHP scripts from the command line, the PHP shell, or serve applications on your web server using Apache or Nginx. Visit the PHP 5 Documentation for more information.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Ubuntu
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren