Upgrade PHP from 7.2 to 7.4 on CentOS 8 and Apache

Hi all,

I host 2 WordPress sites using Apache(httpd) on my droplet and am getting the nagging message to upgrade my version of PHP. I’ve found some tutorials and article on installing PHP, but nothing regarding upgrading from one version of PHP to another, and nothing particularly for CentOS 8. Can anyone give me some pointers or offer any advice on how to safely upgrade from PHP 7.2 to 7.4?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi @jplafata,

In order to upgrade from one PHP version to another just need to install it. There is no actual upgrade process like upgrading from Ubuntu 16 to 18. You just install your new PHP version and make that the default one.

Anyway, let’s see how to install PHP 7.4

To get started, you need to add EPEL & Remi repository from where you will be able to install PHP 7.4 on CentOS 8 Linux.

dnf install

Next once you have the EPEL repository, run:

dnf install

Upon successful addition of EPEL and Remi repositories, execute the command below to get a list of available PHP module streams.

 dnf module list php

You should see an output of PHP version. The one we care about is remi-7.4, the latest PHP stream, To enable the module stream run the following :

dnf module enable php:remi-7.4

Once the PHP remi-7.4 module has been enabled, you can then proceed and install PHP

dnf install php php-cli php-common

Regards, KFSys

This was super helpful to upgrade a CENTOS 8 machine from PHP 7.2 to 7.4. I turned it into a quick script to automate it and to make sure you install all of the PHP 7.2 modules you had previously.


#This script upgrades CENTOS 8 from PHP 7.2 to 7.4

if [ `whoami` != "root" ];
echo "Sorry, gotta be root!"
exit 0

echo "This script will upgrade PHP 7.2 to 7.4 on Centos 8"
echo ""
echo "Press CTRL-C to stop, or any key to continue"
read ans

if [[ `cat /etc/centos-release | grep 'CentOS Linux release 8.'` ]];
echo "You are on Centos 8, proceeding."
echo "Not on Centos 8. Sorry, exiting."
exit 1

echo "These are your current PHP modules installed. Saving to /tmp/php-7.2.modules.txt"
echo ""
rpm -qa | grep php | tee -a /tmp/php-7.2.modules.txt
echo ""

pkgs=`rpm -qa --queryformat "[%{NAME}\n]" | grep php | sort`

dnf install
dnf install
dnf module list php
dnf module reset php
dnf module enable php:remi-7.4

dnf install $pkgs

echo "Upgrade complete."