Guides 11792 Published by

The guide walks you through getting PHP 7.4 up and running on a fresh CentOS 8 or RHEL 8 machine by adding the Remi repository, enabling the correct module stream, and installing core extensions such as php‑fpm, mysqlnd, curl, and gd. It begins with installing dnf‑plugins‑core and epel, then pulls in Remi’s release RPM, activates powertools, resets any existing PHP modules, switches to remi‑7.4 before finally pulling the packages from dnf. After starting and enabling php‑fpm you can verify the installation by checking php -v and the service status while a quick module list confirms that only the Remi 7.4 stream is active. The article also covers common pitfalls like lingering old ini files causing 500 errors, shows how to clean them up, and reloads the service so your web server can serve PHP 7.4 applications without hiccups.



Installing PHP 7.4 on CentOS 8 or RHEL 8

If you’re juggling a fresh CentOS 8 or RHEL 8 box and need PHP 7.4, this is the low‑down that gets it running in minutes—no mystery repositories or half‑baked Docker images.

Why the Remi repo matters

CentOS 8 ships with PHP 7.2 by default. If you skip a repository update, your web apps will stay stuck on 7.2. Remi’s repo keeps the latest streams for every major release, and it plays nicely with RHEL‑style modularity.

Step 1 – Install the base dependencies
sudo dnf install -y dnf-plugins-core epel-release

dnf-plugins-core gives you the config-manager command we’ll use to add a new repo. EPEL supplies extra utilities that Remi’s packages sometimes depend on.

Step 2 – Add and enable the Remi repository
sudo dnf config-manager --set-enabled powertools
sudo rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-8.rpm

powertools is required for PHP‑related packages. The rpm -Uvh line grabs the latest Remi release RPM.

Step 3 – Enable the PHP 7.4 module stream
sudo dnf module reset php
sudo dnf module enable php:remi-7.4

The first command clears any previous PHP modules that might be lurking from a prior install. The second pins you to Remi’s 7.4 build.

Installing the core packages
sudo dnf install -y php php-cli php-fpm php-mysqlnd php-zip php-json php-curl php-gd

php-fpm is the preferred FastCGI handler on RHEL‑style distros. The extras (mysqlnd, curl, etc.) cover common extensions you’ll need for WordPress, Laravel, or any PHP app that talks to a database.

Step 4 – Start and enable php‑fpm
sudo systemctl start php-fpm
sudo systemctl enable php-fpm

If you forget this, your Apache/Nginx will try to use the old mod_php module (if it’s still installed) or just fail altogether.

Step 5 – Verify
php -v
systemctl status php-fpm

You should see “PHP 7.4.x” and a running service. If php -v shows something older, double‑check that you didn’t leave the default module stream enabled. Run:

sudo dnf module list php

and make sure only remi-7.4 is active.

Troubleshooting a common pitfall

I’ve seen this happen on production servers: after installing PHP 7.4, the site starts throwing 500 errors because an old php.ini file from 7.2 still lives in /etc/php-fpm.d/. The culprit is usually a stray config block that overrides the new module’s defaults.

Fix: Remove or rename any .conf files under /etc/php-fpm.d/ that reference legacy PHP paths, then reload:

sudo rm /etc/php-fpm.d/old.ini
sudo systemctl reload php-fpm

A quick look at the error log (journalctl -u php-fpm) usually points you straight to the offending file.

Wrapping it up

You’ve got PHP 7.4, a running FPM service, and all the common extensions installed. Plug your web server in (Apache with mod_proxy_fcgi or Nginx), point it at /run/php-fpm/www.sock, and you’re good to go.