How to Upgrade to PHP 7.4 on CentOS 7

I have seen several different versions of this process, but none of them worked… Here is the summary, but make sure you keep track of all changes in case you need to revert.

Note: If you are using CentOS Web Panel, the update can be done from the dashboard.

At the bottom of the dashboard, click on the tiny Edit sign next to the PHP Switcher.

PHP Version cwp dashSelect the desired PHP version and the extensions needed.

PHP Version switcher

Then click on the Save & Build button.

The PHP Compiler has been started in the background. The process can take up to 30 minutes and you will see high CPU usage while this happens.

overload from php update

You can follow the process in /var/log/php-rebuild.log

php rebuild log

When the update is completed, you will be able to see the new PHP version:

You can also check the version in Putty:

Putty PHP version

# php -v
Failed loading /usr/local/ioncube/ /usr/local/ioncube/ cannot open shared object file: No such file or directory
PHP 7.4.7 (cli) (built: Jun 20 2020 10:12:23) ( NTS )

You can see the new version, but also that Ioncube loader isn’t working.

Warning: Even though we are already at 7.4.7, there are still missing extensions that may break your site. Therefore make sure you don’t delete PHP 7.3 and proceed with caution, because you can break WordPress plugins. This is the reason why even hosts like SiteGround still have 7.3 listed as their managed PHP version.

Manual Update

Version #1

1. Verify current version of PHP

Type in the following to see the current PHP version:

php -v

The output should be something like this:

PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

2. Install the REMI and EPEL repositories

If you don’t already have them, install the Remi and EPEL repositories:

rpm -Uvh
rpm -Uvh

Enable the Remi repository globally:


Under the section that looks like [remi] make the following changes (enabled=0):

name=Remi's RPM repository for Enterprise Linux 7 - $basearch

Enable the Remi PHP7.4 Repository:


Under the section that looks like [remi-php74] make the following changes (enabled=1):

name=Remi's PHP 7.4 RPM repository for Enterprise Linux 7 - $basearch

3. Install required extensions

You can list the existing extensions using command below :

yum --enablerepo=remi-php73 search php73-

Simply prefix php7.4- with an extension that you need to install.
For example to get the php-curl extension use php7.4-curl

To view enabled modules, run:

$ php --modules

You can run the following command to search other available PHP modules under configured yum repositories. Below example command search for all modules for PHP 7.3.

yum --enablerepo=remi-php73 search php | grep php73
sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
yum --enablerepo=remi-php70 install php74-cli php74-common php74w-bcmath php74-dba php74-devel php74-embedded php74-fpm php74-gd php74-imap php74-interbase php74-intl php74-ldap php74-mbstring php74-mcrypt php74-mysql php74-odbc php74-opcache php74-pdo php74-pdo_dblib php74-pear php74-process php74-pspell php74-recode php74-tidy php74-xml php74-xmlrpc

4. Upgrade PHP 5.4 to PHP 7.4

Now we can upgrade PHP. Just type in the following command:

yum -y upgrade php*

This above procedure installed the updated PHP, however it isn’t active.


Version #2

Here is another version. Most steps are similar, but there are additional ones:

1. Download Remi and EPEL Repository packages

First, download Remi and EPEL Repository packages:

$ wget -q
$ wget -q

2. Enable Remi and EPEL Repository

Install both previously downloaded packages and enable Remi PHP 7 repo:

# rpm -i remi-release-7.rpm epel-release-latest-7.noarch.rpm

# yum-config-manager --enable remi-php70
# yum-config-manager --enable remi-php71
# yum-config-manager --enable remi-php72
# yum-config-manager --enable remi-php73
# yum-config-manager --enable remi-php74

Current latest PHP version from Remi repository is 7.4. Amend the above command for any other subsequent PHP releases.

??? This may be an alternative comman:

yum --enablerepo=remi update remi-release

These are the missing steps cut from another tutorial:

Step 5 – Now delete current PHP installation but make sure you stopped Apache first:

service httpd stop

yum -y remove php

Step 6 – Finally, issue this command to install PHP 7.4 with all necessary modules:

yum –enablerepo=remi-php74 install php74-php php74-php-pear php74-php-bcmath php74-php-pecl-jsond-devel php74-php-mysqlnd php74-php-gd php74-php-common php74-php-fpm php74-php-intl php74-php-cli php74-php php74-php-xml php74-php-opcache php74-php-pecl-apcu php74-php-pecl-jsond php74-php-pdo php74-php-gmp php74-php-process php74-php-pecl-imagick php74-php-devel php74-php-mbstring

Step 7 – Next, at this point, you can simply stop the old PHP-fpm service and start the newly installed PHP74-fpm

(Obviously you should use the alternative if you have php-cgi)

service php-fpm stop

service php70-php-fpm start

Step 8 – Finally you can delete the old php symblink and create a new one:

rm /usr/bin/php
ln -s /usr/bin/php70 /usr/bin/php

Also do not forget to restart Apache service / httpd:

service httpd restart

These may or may not be relevant:

If you are using Apache as your web server then just restart the Apache service using the following command and you are good to go:

sudo systemctl restart httpd

Unlike Apache, Nginx doesn’t have built-in support for processing PHP files so we need to install a separate application such as PHP FPM which will handle the PHP file

To install the PHP FPM package run the following command:

sudo yum install php-fpm

By default PHP FPM will run as user apache on port 9000. We’ll change the user to nginx and switch from TCP socket to Unix socket. To do so edit the lines highlighted in yellow:

user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.owner = nginx = nginx

Make sure the /var/lib/php directory has the correct ownership:

chown -R root:nginx /var/lib/php

Once you made the changes, enable and start the PHP FPM service:

sudo systemctl enable php-fpm
sudo systemctl start php-fpm

Next, edit the Nginx virtual host directive and add the following location block so that Nginx can process PHP files:

server {

    # . . . other code

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

For the new configuration to take effect, restart the Nginx service:

sudo systemctl restart nginx