In this article, you will learn how to install the latest PHP version 8 on CentOS 8, RHEL 8 Linux distributions.

PHP is one of the most popular server-side scripting languages. Most of the websites on the internet are using PHP including Facebook, Yahoo, Wikipedia. There are many frameworks that are also built with PHP, like WordPress, Codeigniter, Laravel, etc.

Even this website is using PHP. This blog is built on the WordPress framework which is written in PHP.

So let’s go through the complete guide on how to install the latest stable release of PHP 8.0 on CentOS and REHL.

Installing PHP 8 on CentOS and RHEL

As PHP 8 is recently released so it is not available in the default repositories of various distributions. So you have to add the Remi-repository to get the latest PHP.

First of all, you have to install the Remi repository configuration package. This given command will also install yum-utils and enable the epel-release repository.

sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
Adding remi repository in centos

After adding the remi-repository, you can search for available PHP versions.

sudo dnf module list php

Output:

Extra Packages for Enterprise Linux Modular 8 - x86_64                         32 kB/s |  98 kB     00:03    
Extra Packages for Enterprise Linux 8 - x86_64                                549 kB/s | 8.4 MB     00:15    
Remi's Modular repository for Enterprise Linux 8 - x86_64                     331 kB/s | 697 kB     00:02    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                    727 kB/s | 1.6 MB     00:02    
CentOS-8 - AppStream
Name             Stream               Profiles                               Summary                          
php              7.2 [d]              common [d], devel, minimal             PHP scripting language           
php              7.3                  common [d], devel, minimal             PHP scripting language           

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name             Stream               Profiles                               Summary                          
php              remi-7.2             common [d], devel, minimal             PHP scripting language           
php              remi-7.3             common [d], devel, minimal             PHP scripting language           
php              remi-7.4             common [d], devel, minimal             PHP scripting language           
php              remi-8.0             common [d], devel, minimal             PHP scripting language           

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

You can see at the bottom, PHP 8 is available through the remi-repository. So if you already have PHP installed, then simply reset the module and enable the latest PHP 8.

sudo dnf module reset php
sudo dnf module enable php:remi-8.0

Finally, to install PHP 8 in your Linux system, use the installation command.

sudo dnf install php

This will install the PHP 8 along with the required modules in your Linux distribution. To verify the installed version, use the php command.

php -v
php 8 version

Also, check out: How to install PHP 8 on Ubuntu 20.04 / Debian 10

Watch Video guide on YouTube

Additionally, You can also watch a step-by-step video guide on YouTube to get a better understanding of it.

Conclusion

So that’s it on how to install PHP 8 on CentOS and RHEL. Do subscribe to the LinuxH2O Youtube channel. Till then take care and keep enjoying Linux.