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 https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

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!

About the author

mvps

MVPS.net provides reliable, high-quality VPS services at competitive prices. The team has extensive experience in virtualized environments and focuses on delivering consistent performance and stability. Services are available across multiple locations without compromising quality — feel free to get in touch to learn more.

By mvps

Categories