Tutorials  /  Ubuntu

Install PHP 5.6 on Ubuntu 22.04 with PHP-FPM and Apache Configuration

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

PHP (Hypertext Preprocessor) is an open-source, server-side scripting language widely used in web development. Although PHP 5.6 has reached end of life, some teams still install PHP 5.6 on Ubuntu to power dynamic sites, handle forms, manage sessions, and connect to MySQL or PostgreSQL. Many organizations retain this release due to legacy apps or compatibility requirements. PHP also offers a rich set of extensions, keeping it adaptable for modern scenarios.

This guide shows how to install PHP 5.6 on Ubuntu 22.04. You will add the required repositories, install PHP modules, configure PHP-FPM, and integrate it into your applications via PHP-FPM.

Prerequisites

Have access to an Ubuntu 22.04 instance as a non-root sudo user.

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 →

Install the PHP PPA Repository

PHP 5.6 is deprecated and not available in Ubuntu’s default repositories. You must add a Personal Package Archive (PPA) that maintains older PHP builds. The Ondřej Surý PPA is commonly used for installing legacy PHP versions. Follow these steps to add the PHP PPA.

Update the APT package index

console

Copy

Console
$ sudo apt update

Add the ondrej/php PPA

console

Copy

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

Press Enter to proceed with adding the repository to your system.

...

WARNING: add-apt-repository is broken with non-UTF-8 locales, see

https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

Console
# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

More info: https://launchpad.net/~ondrej/+archive/ubuntu/php

Adding repository.

Press [ENTER] to continue or Ctrl-c to cancel.

If you hit non-UTF-8 locale errors

Run the following to add the repository with a UTF-8 locale.

console

Copy

Console
$ sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

Refresh APT indexes

console

Copy

Console
$ sudo apt update

Install PHP 5.6 on Ubuntu

Use the following steps to install PHP 5.6 and essential modules commonly required by web applications.

Install PHP 5.6

console

Copy

Console
$ sudo apt install -y php5.6

Install common PHP 5.6 modules

console

Copy

Console
$ sudo apt install -y php5.6-mysql php5.6-xml php5.6-curl php5.6-cli

When asked to restart services, use Tab to select and press Enter.

Verify the installed PHP version

console

Copy

Console
$ php -v

Your output should resemble the following.

Code
PHP 5.6.40-81+ubuntu22.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

Install PHP 5.6 FPM

PHP-FPM (FastCGI Process Manager) is a FastCGI implementation that handles PHP requests efficiently. It offers better resource usage and performance than traditional methods. PHP-FPM runs PHP processes independently, improving memory management, concurrency handling, and integration capabilities. Follow these steps to install PHP 5.6 FPM.

Install the PHP 5.6 FPM package

console

Copy

Console
$ sudo apt install php5.6-fpm

When prompted to restart services, use Tab to select and press Enter.

Start PHP 5.6 FPM

console

Copy

Console
$ sudo systemctl start php5.6-fpm

Enable PHP 5.6 FPM at boot

console

Copy

Console
$ sudo systemctl enable php5.6-fpm

Confirm PHP 5.6 FPM status

console

Copy

Console
$ sudo systemctl status php5.6-fpm

Your output should be similar to this.

Code
● php5.6-fpm.service - The PHP 5.6 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php5.6-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2025-03-20 22:54:20 UTC; 3min 27s ago Docs: man:php-fpm5.6(8) Main PID: 16489 (php-fpm5.6) Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 3 (limit: 2217) Memory: 11.9M CPU: 42ms CGroup: /system.slice/php5.6-fpm.service ├─16489 "php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ├─16490 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""> └─16491 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""> Mar 20 22:54:20 test-server systemd[1]: php5.6-fpm.service: Deactivated successfully. Mar 20 22:54:20 test-server systemd[1]: Stopped The PHP 5.6 FastCGI Process Manager. Mar 20 22:54:20 test-server systemd[1]: Starting The PHP 5.6 FastCGI Process Manager... Mar 20 22:54:20 test-server systemd[1]: Started The PHP 5.6 FastCGI Process Manager.

Test and Use PHP 5.6

Use the following steps to create a PHP test file, configure your web server, and wire PHP-FPM to handle PHP requests for dynamic applications.

Create a PHP info file

Create a PHP information file using any editor such as nano.

console

Copy

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

Add the PHP info snippet

Add the following PHP code to display configuration details.

php

Copy

PHP
<?php phpinfo(); ?>

Save and close the file.

Enable required Apache modules

Enable the proxy_fcgi module so Apache can communicate with PHP-FPM and the setenvif module for managing environment variables.

console

Copy

Console
$ sudo a2enmod proxy_fcgi setenvif

Your output should look like this:

Code
Considering dependency proxy for proxy_fcgi: Enabling module proxy. Enabling module proxy_fcgi. Module setenvif already enabled To activate the new configuration, you need to run: systemctl restart apache2

Restart Apache to apply modules

console

Copy

Console
$ sudo systemctl restart apache2

Configure Apache to use PHP-FPM

Edit the default site to process PHP via PHP-FPM.

console

Copy

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

Add the following block inside the <VirtualHost *:80> section.

apache

Copy

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

console

Copy

Console
$ sudo apache2ctl -t

Your output should be similar to the following:

Code
Syntax OK

If you see Syntax OK, your configuration is valid.

Restart Apache to apply changes

console

Copy

Console
$ sudo systemctl restart apache2

Allow HTTP through the firewall

console

Copy

Console
$ sudo ufw allow 80

Reload the firewall

console

Copy

Console
$ sudo ufw reload

Access the PHP info page

Open the /info.php path using your server IP in a browser such as Chrome.

http:///info.php

PHP information page

Warning

PHP 5.6 no longer receives security updates. For stronger security and performance, upgrade to a newer PHP release. Use PHP 5.6 only when required for legacy software.

Conclusion

You have installed PHP 5.6 on Ubuntu 22.04 and configured PHP-FPM to serve web requests efficiently. You installed PHP 5.6 from a custom PPA, set up PHP-FPM for performance, and configured PHP-FPM to handle PHP traffic on the server. Visit the official PHP documentation for additional details on PHP 5.6 security best practices and configuration options.

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?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

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