Tutorials  /  Linux Basics

Install PHP 5.6 on Rocky Linux 9 with PHP-FPM & Nginx

Ccentron Redaktion · August 2025 ·8 min read ·Linux Basics, Tutorial

PHP (Hypertext Preprocessor) is a widely-used server-side scripting language ideal for web development. Version 5.6 of PHP offers various performance enhancements, compatibility with legacy extensions, and support for dynamic modules. This version enables dynamic site creation, data processing, and seamless database integration with systems like MySQL, Valkey, and PostgreSQL.

This guide demonstrates how to install PHP 5.6 on Rocky Linux 9. Although this version has reached its end-of-life, several applications still rely on it and require specific modules. You will learn how to install PHP 5.6 and configure PHP-FPM to connect with backend services.

Requirements

Before proceeding, ensure you have:

  • Access to a Rocky Linux 9 server as a non-root user with sudo permissions
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Install Required Dependencies for PHP 5.6

PHP 5.6 isn't part of the standard repositories or third-party sources for Rocky Linux 9. It requires OpenSSL 1.0.2 to function correctly. Follow these steps to install dependencies and build PHP 5.6 from source.

Check Current OpenSSL Version

Console
$ openssl --version

You should see something similar to:

OpenSSL 3.2.2 4 Jun 2024 (Library: OpenSSL 3.2.2 4 Jun 2024)

Update Package Index

Console
$ sudo dnf update -y

Install PHP and OpenSSL Dependencies

Console
$ sudo dnf install -y gcc gcc-c++ make bison autoconf libxml2-devel bzip2-devel curl-devel libjpeg-devel libpng-devel libXpm-devel freetype-devel gmp-devel  libmcrypt-devel readline-devel libxslt-devel libicu-devel libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libxslt-devel perl-core zlib-devel

Install OpenSSL 1.0.2

Go to the Source Directory

Console
$ cd /usr/local/src

Download and Extract OpenSSL

Console
$ sudo wget https://www.openssl.org/source/openssl-1.0.2u.tar.gz
$ sudo tar -xvzf openssl-1.0.2u.tar.gz
$ cd openssl-1.0.2u

Configure and Compile OpenSSL

Console
$ sudo ./config --prefix=/usr/local/openssl-1.0.2 --openssldir=/usr/local/openssl-1.0.2 shared zlib
$ sudo make -j$(nproc)
$ sudo make install

Set Up OpenSSL Environment Variables

Console
$ echo 'export LDFLAGS="-Wl,-rpath,/usr/local/openssl-1.0.2/lib"' >> ~/.bashrc
$ echo 'export CPPFLAGS="-I/usr/local/openssl-1.0.2/include"' >> ~/.bashrc
$ echo 'export PKG_CONFIG_PATH="/usr/local/openssl-1.0.2/lib/pkgconfig"' >> ~/.bashrc
$ echo 'export PATH="/usr/local/openssl-1.0.2/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

Confirm OpenSSL Version

Console
$ openssl version -a

Expected output: OpenSSL 1.0.2u 20 Dec 2019

Build and Install PHP 5.6 from Source

Download PHP Source

Console
$ cd /usr/local/src
$ sudo wget https://museum.php.net/php5/php-5.6.40.tar.gz
$ sudo tar -xzf php-5.6.40.tar.gz
$ cd php-5.6.40

Configure PHP Compilation Options

Console
$ sudo ./configure --prefix=/usr/local/php-5.6.40 --with-openssl=/usr/local/openssl-1.0.2 --enable-mbstring --with-pdo-mysql --with-mysqli --enable-fpm --with-openssl=/usr/local/openssl-1.0.2

This sets the installation path, includes extensions like mbstring and MySQL, and integrates OpenSSL 1.0.2. If you see errors, check for missing dependencies.

Compile and Install PHP

Console
$ sudo make -j$(nproc)
$ sudo make install

Upon successful build and install, you'll see output including:

  • Installing shared extensions
  • Installing PHP CLI and FPM binaries
  • Generating phar.phar and other PHP components

Confirm PHP Version

Console
$ /usr/local/php-5.6.40/bin/php -v

Sample output:

PHP 5.6.40 (cli) (built: Mar 19 2025 20:03:18)

Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Install and Configure PHP 5.6 FPM on Rocky Linux 9

PHP-FPM (FastCGI Process Manager) is included in the PHP 5.6 source and improves performance by managing PHP processes more efficiently. The following steps guide you through installing PHP-FPM 5.6 and setting it up as a service on Rocky Linux 9.

Set Up PHP-FPM Configuration

Copy the default PHP production configuration file:

Console
$ sudo cp /usr/local/src/php-5.6.40/php.ini-production /usr/local/php-5.6.40/lib/php.ini

Copy the FPM configuration templates:

Console
$ sudo cp sapi/fpm/php-fpm.conf.in /usr/local/php-5.6.40/etc/php-fpm.conf
$ sudo mkdir -p /usr/local/php-5.6.40/etc/php-fpm.d
$ sudo cp sapi/fpm/www.conf.in /usr/local/php-5.6.40/etc/php-fpm.d/www.conf

Add PHP 5.6 binaries to your system PATH and reload the shell configuration:

Console
$ echo 'export PATH="/usr/local/php-5.6.40/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

Create a non-login service user for PHP-FPM:

Console
$ sudo useradd -r -s /sbin/nologin www-data

Edit PHP-FPM Configuration Files

Modify the main PHP-FPM config file:

Console
$ sudo nano /usr/local/php-5.6.40/etc/php-fpm.conf

Update these entries in the file:

Code
pid = /run/php56-fpm/php56-fpm.pid
user = www-data
group = www-data

Next, edit the default pool configuration:

Console
$ sudo nano /usr/local/php-5.6.40/etc/php-fpm.d/www.conf

Update the following values:

Code
user = www-data
group = www-data
listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

Prepare FPM Runtime and Log Directories

Create necessary directories with correct permissions:

Console
$ sudo mkdir -p /run/php56-fpm
$ sudo chown -R www-data:www-data /run/php56-fpm
$ sudo chmod 755 /run/php56-fpm
$ sudo mkdir -p /usr/local/php-5.6.40/var/log
$ sudo chown -R www-data:www-data /usr/local/php-5.6.40/var/log
$ sudo chmod -R 755 /usr/local/php-5.6.40/var/log

Validate PHP-FPM Configuration

Test for syntax errors in the FPM configuration:

Console
$ sudo /usr/local/php-5.6.40/sbin/php-fpm -t

Expected output:

[18-Apr-2025 20:34:37] NOTICE: configuration file /usr/local/php-5.6.40/etc/php-fpm.conf test is successful

Set Up PHP 5.6 FPM as a Systemd Service

Create a System Service File

Open a new systemd service file for PHP 5.6 FPM:

Console
$ sudo nano /etc/systemd/system/php56-fpm.service

Add the following content:

Code
[Unit]
Description=PHP 5.6 FastCGI Process Manager
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/php-5.6.40/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php-5.6.40/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
Restart=always
PrivateTmp=true
User=www-data
Group=www-data
WorkingDirectory=/usr/local/php-5.6.40

[Install]
WantedBy=multi-user.target

Activate and Start PHP-FPM Service

Reload systemd and enable the service:

Console
$ sudo systemctl daemon-reload
$ sudo systemctl enable php56-fpm
$ sudo systemctl start php56-fpm

Check the PHP-FPM Service Status

Verify that the service is active:

Console
$ sudo systemctl status php56-fpm

Expected output:

● php56-fpm.service - PHP 5.6 FastCGI Process Manager

Loaded: loaded (/etc/systemd/system/php56-fpm.service; enabled; preset: disabled)

Active: active (running) since Wed 2025-03-19 20:28:17 UTC; 19s ago

Main PID: 223702 (php-fpm)

Tasks: 3 (limit: 23116)

Memory: 2.5M

CPU: 32ms

CGroup: /system.slice/php56-fpm.service

├─223702 "php-fpm: master process (/usr/local/php-5.6.40/etc/php-fpm.conf)"

├─223703 "php-fpm: pool www"

└─223704 "php-fpm: pool www"

The service is running successfully, as indicated by the “active (running)” status in the output.

Testing and Running PHP 5.6 on Rocky Linux 9

To confirm that PHP 5.6 is functioning correctly on your Rocky Linux 9 system, follow the steps below.

Verify PHP Version

Console
$ php --version

Expected output:

PHP 5.6.40 (cli) (built: Apr 18 2025 14:44:08)

Zend Engine v2.6.0, Copyright (c) 1998–2016 Zend Technologies

Create and Run a PHP Script

Create a new script file in your current directory:

Console
$ sudo nano app.php

Insert the following code into the file:

PHP
<?php

echo "Greetings from centron! \n";

?>

Execute the script:

Console
$ php app.php

Output:

Greetings from centron!

Using PHP 5.6 with Nginx on Rocky Linux 9

To serve dynamic content via PHP 5.6 FPM and Nginx, follow the steps below.

Install and Start Nginx

Console
$ sudo dnf install -y nginx
$ sudo systemctl start nginx

Check Nginx Status

Console
$ sudo systemctl status nginx

Sample output:

● nginx.service - The nginx HTTP and reverse proxy server

Loaded: loaded

Active: active (running)

Create Nginx Virtual Host Configuration

Open a new server block configuration file:

Console
$ sudo nano /etc/nginx/conf.d/app.example.conf

Add the following configuration (replace app.example.com with your domain):

Code
server {
    listen 80;
    server_name app.example.com;
    root /var/www/app.example.com;

    index index.php index.html index.htm;

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Validate and Restart Nginx

Console
$ sudo nginx -t
$ sudo systemctl restart nginx

Set Up Web Root and PHP Info Page

Console
$ sudo mkdir -p /var/www/app.example.com
$ sudo nano /var/www/app.example.com/info.php

Insert the following code into info.php:

PHP
<?php 

phpinfo();

?>

This displays PHP environment details when accessed via the browser.

Configure SELinux and Firewall

Allow Nginx to connect to PHP-FPM and open HTTP access through the firewall:

Console
$ sudo setsebool -P httpd_can_network_connect 1
$ sudo firewall-cmd --add-service=http --permanent
$ sudo firewall-cmd --reload

Restart Services

Console
$ sudo systemctl restart php56-fpm
$ sudo service nginx restart

Verify Setup in Browser

Visit http://app.example.com in your browser. The PHP information page should be visible, confirming the web server and PHP-FPM integration is successful.

Security Notice

Warning: PHP 5.6 is no longer maintained and does not receive security patches. Use it only for legacy systems that cannot migrate to modern versions.

Conclusion

You have successfully installed PHP 5.6 and PHP-FPM on Rocky Linux 9. You can now run legacy applications on your server. However, for better security and performance, consider upgrading to a supported PHP version. Refer to the official PHP documentation for more details and migration tips.

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 Linux Basics
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