If you are an RHEL 8.5 user and a PHP enthusiast, this article guide is the right fit for you. PHP is a globally-renowned scripting language that has helped developers and users come up with impressive web-based applications.
If you are a current user of older PHP versions like 7.2/7.4 or just need a fresh install of PHP 8 on your RHEL 8.5 system, this article is the perfect reference point.
Since the current PHP version release is at 8.x, its many new features and optimizations include improved error handling, type system, & consistency, named JIT, match expression, attributes, arguments, nullsafe operator, constructor property promotion, and union types.
Other improvements include saner string to number comparison, consistent type errors for internal functions, just-in-time compilation, syntax tweaks, system, and error handling improvements.
Installing PHP 8 on RHEL Linux
The main prerequisite for this article is to ensure you are a root/sudoer user on the RHEL system you are using.
To determine the RHEL operating system version you are using, execute the following command on your terminal/command line:
$ cat /etc/redhat-release Red Hat Enterprise Linux release 8.5 (Ootpa)
Your RHEL system needs to be up-to-date for it to be performant and get rid of security vulnerabilities like bugs through patch fixes and application upgrades.
$ sudo yum update -y
Next, you need to enable EPEL and Remi repositories, which are responsible for creating, maintaining, and managing high-quality Enterprise Linux packages.
$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
The Remi repository on the other hand will be useful in providing the PHP 8.x version you will install on your RHEL system. This repo hugely contributes to meeting the objectives/requirements of a LAMP/LEMP stack.
$ sudo dnf install dnf-utils https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
Your RHEL system is now ready to install and explore what PHP 8.x has to offer. To preview the PHP modules available for your RHEL system, execute the following command:
$ sudo dnf module list php
As you can see, the above command has revealed several PHP versions ranging from version 7.2 to 8.1 as per Remi’s Modular repository for Enterprise Linux 8 – x86_64.
If you are already using an older PHP version like 7.2, 7.3, or 7.4 and wish to upgrade to 8.0 or 8.1, the best course of action is to reset PHP to that preferred version.
$ sudo dnf module reset php
Afterward, you can now enable the PHP module you wish to install (8.0 or 8.1) from the Remi repository using the following command:
$ sudo dnf module enable php:remi-8.1
Next, the PHP install command should now showcase PHP 8.1 as the preferred installation package.
$ sudo dnf install php
After the installation process completes, confirm the PHP version you just installed.
$ php --version
If you wish to install other php modules like fpm, common, mysqlnd, etc., the command structure to use should look like the following:
$ sudo dnf install php-{fpm,common,mysqlnd,cli}
This article has shown us to install/upgrade to PHP 8.x on an RHEL 8.5 system. You can now comfortably kick off or continue your LAMP/LEMP projects.