How to install PHP 7.3 or PHP 7.4 on CentOS 8


It’s always a best practice to keep your software updated. While CentOS is generally more conservative on major version updates of its applications, we consider you should always use the latest PHP version and make sure your application is keeping up with the changes done in PHP.

To update your CentOS 8 PHP version to 7.3 or 7.4, we will use the REMI repository. REMI has been the trusted alternative PHP repository for PHP for years and it’s been widely used with CentOS 7 which is still shipped with PHP 5.6.

We start by importing the EPEL and REMI repos:

dnf -y install
dnf -y install

And next we configure the PHP 7.3 or PHP 7.4 modules:

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

For PHP 7.3, simply replace 7.4 with 7.3 in the above command.

We should make sure the system is updated, by running:

dnf -y update

And we can test the PHP version by running:

php -v

The result should be something like:

[root@vps ~]# php -v
PHP 7.4.4 (cli) (built: Mar 17 2020 10:40:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.4, Copyright (c), by Zend Technologies

This is all. You now have PHP 7.4 installed. As soon as PHP 7.5 is released and reaches stable, you should be able to use this guide to upgrade.

In the end, we should all send our thanks to Remi for creating and maintaining this repository!

Recent Posts