Tutorials  /  Linux Basics

Install PHP 7.4 with PHP-FPM on Rocky Linux 9 Guide

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

PHP is a popular server-side scripting language used to develop dynamic web applications. PHP 7.4, the last minor release of the PHP 7 branch, introduces features like typed properties, arrow functions, and improved performance. Many older applications continue to depend on PHP 7.4 for compatibility with existing code and services.

This guide covers the steps to install PHP 7.4 on Rocky Linux 9. It includes installing PHP, setting up PHP-FPM, and enabling essential extensions needed for dynamic applications.

Important Notice

PHP 7.4 reached its End of Life (EOL) in November 2022 and no longer receives security patches. Use it only if required for legacy projects and plan to migrate to a supported PHP version to maintain security and support.

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 →

Prerequisites

  • Access to a Rocky Linux 9 system with a non-root sudo-enabled user.

Install the EPEL and Remi Repositories

By default, PHP 7.4 is not available in the DNF package sources. You must add the EPEL and Remi repositories to access the latest dependencies for Rocky Linux 9, including multiple PHP versions like PHP 7.4. Follow these steps:

Update the DNF package index

Console
$ sudo dnf makecache

Install the EPEL repository

Console
$ sudo dnf install epel-release -y

Install the Remi repository

Console
$ sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y

Verify that Remi is enabled

Console
$ sudo dnf repolist | grep remi

This command lists the active Remi repositories available on the system.

Install PHP 7.4

To install PHP 7.4 on Rocky Linux 9, you must enable the correct module and then install PHP with its required extensions. Follow the steps below:

Update the DNF package index

Console
$ sudo dnf makecache

Search for PHP 7.4 packages

Console
$ sudo dnf search php74

Example output:

Code
=============================================================== Name Exactly Matched: php74 ================================================================
php74.x86_64 : Package that installs PHP 7.4
============================================================== Name & Summary Matched: php74 ===============================================================
php74-php-pecl-http-message-devel.x86_64 : php74-php-pecl-http-message developer files (headers)
php74-php-pecl-pcsc-devel.x86_64 : php74-php-pecl-pcsc developer files (header)
php74-php-pecl-propro-devel.x86_64 : php74-php-pecl-propro developer files (header)
......

Enable the PHP 7.4 module

Console
$ sudo dnf module enable php:remi-7.4 -y

Install PHP 7.4

Console
$ sudo dnf install php74 -y

Install common PHP extensions

Console
$ sudo dnf install php74-php-mysql php74-php-zip php74-php-xml php74-php-json php74-php-mbstring php74-php-pdo php74-php-gd -y

This installs:

  • php74-php-mysql: MySQL database connectivity.
  • php74-php-zip: ZIP archive support.
  • php74-php-xml: XML parsing with DOM, SimpleXML, etc.
  • php74-php-json: JSON encode/decode functionality.
  • php74-php-mbstring: Multibyte string handling (e.g., UTF-8).
  • php74-php-pdo: Database abstraction with PDO.
  • php74-php-gd: Image processing (resize, crop, watermark).

Check the installed PHP version

Console
$ php74 --version

Example output:

Code
PHP 7.4.33 (cli) (built: Mar 18 2025 06:44:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Install PHP 7.4-FPM

PHP-FPM (FastCGI Process Manager) is a high-performance PHP handler that operates with a pool-based process management model. It enables PHP to communicate efficiently with web servers and services over UNIX sockets or TCP ports. In PHP 7.4, PHP-FPM runs a dedicated process pool, making it essential for serving dynamic applications. Follow these steps to install and set up PHP 7.4 FPM:

Install the PHP 7.4 FPM package

Console
$ sudo dnf install php74-php-fpm -y

Verify PHP 7.4 FPM installation

Console
$ sudo dnf list installed | grep php-fpm

This command outputs details about the installed PHP-FPM package.

Enable and start PHP 7.4 FPM

Console
$ sudo systemctl enable php74-php-fpm
$ sudo systemctl start php74-php-fpm

Check the status of PHP 7.4 FPM

Console
$ sudo systemctl status php74-php-fpm

Example output:

YAML
● php74-php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php74-php-fpm.service; enabled; preset: disabled)
     Active: active (running) since Fri 2025-06-06 03:22:20 UTC; 1h 2min ago
   Main PID: 5790 (php-fpm)
     Status: "Processes active: 0, idle: 5, Requests: 17, slow: 0, Traffic: 0req/sec"
......

Configure PHP 7.4-FPM

PHP-FPM uses pool configurations to handle PHP requests with defined listening addresses, user permissions, and performance parameters. Follow the steps below to check the default configuration directory and edit the default pool settings for PHP requests.

List configuration files

Console
$ ls /etc/opt/remi/php74/

Example output:

Code
opt  php.d  php-fpm.conf  php-fpm.d  php.ini  pki  pm  skel  sysconfig  X11  xdg  xinetd.d

Key files/directories:

  • php-fpm.conf: Global settings for PHP-FPM before pool configs are applied.
  • php-fpm.d: Contains individual pool configurations.

Edit the default pool configuration

Console
$ sudo nano /etc/opt/remi/php74/php-fpm.d/www.conf

Check the pool name:

Code
[www]

Check and modify user/group if necessary (e.g., change from apache to nginx for Nginx servers):

Code
user = apache
group = apache

Verify the listening socket path:

Code
listen = /var/opt/remi/php74/run/php-fpm/www.sock

Review process management defaults (adjust to your server resources):

Code
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35

Restart PHP-FPM

Console
$ sudo systemctl restart php74-php-fpm

Test PHP 7.4

PHP provides both a CLI and integration with web servers via PHP-FPM. Below are tests for each method.

Test PHP via CLI

Create a file named test.php:

Console
$ sudo nano test.php

Add the following code:

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

Run the script:

Console
$ php74 test.php

Expected output:

Code
Greetings from centron

Test PHP-FPM with Apache

Check if Apache is installed:

Console
$ rpm -q httpd

If not installed, add it:

Console
$ sudo dnf install httpd -y

Enable and start Apache:

Console
$ sudo systemctl enable httpd
$ sudo systemctl start httpd

Edit Apache config to process PHP via PHP-FPM:

Console
$ cd /etc/httpd/conf.d
$ sudo nano welcome.conf

Insert before the <LocationMatch> block:

Code
SetHandler "proxy:unix:/var/opt/remi/php74/run/php-fpm/www.sock|fcgi://localhost/"

Navigate to the default web root and create info.php:

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

Add:

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

Configure SELinux and Firewall

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

Open your browser and visit:

http://your_server_ip/info.php

Conclusion

In this tutorial, you installed PHP 7.4 on Rocky Linux 9 and configured PHP-FPM to serve applications via a web server. PHP remains a powerful server-side scripting language for building dynamic applications. While PHP 7.4 is now end-of-life and should only be used when required for legacy compatibility, it can still run frameworks and platforms such as Laravel, Symfony, or certain WordPress versions. For more details, consult the official PHP documentation.

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