How to Install PHP 8.4 in RHEL 9

PHP is a popular programming language used for building dynamic web applications. With the release of PHP 8.4, developers gain access to new features and improvements.

For this guide, we will be operating the system as root, if that is not the case for you, make use of the sudo command to acquire root privileges.

Step 1: Update System Packages

To install the latest version of PHP, first, you need to update your system’s package repository and install newer available packages using the dnf command.

sudo dnf update
Update System Packages
Update System Packages

Step 2: Enable EPEL Repository in RHEL

Next, install the epel-release package, which provides additional packages for the RHEL system.

sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Enable EPEL Repository in RHEL
Enable EPEL Repository in RHEL

Step 3: Enable Remi Repository in RHEL

Next, you need to enable the Remi repository which offers the latest PHP versions for RHEL systems.

sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Enable Remi Repository in RHEL
Enable Remi Repository in RHEL

Step 4: Install PHP 8.4 in RHEL

If you have PHP 8.3 already installed, you need to reset the PHP module to remove it properly before installing PHP 8.4.

sudo dnf module reset php:remi-8.3

This command will disable the PHP 8.3 module and prepare the system to install the next PHP version without conflicts.

Once PHP 8.3 has been reset, you should update your system’s package repository to make sure everything is up-to-date and install PHP 8.4 along with the necessary extensions..

sudo dnf update
sudo dnf module install php:remi-8.4
Install PHP 8.4 in RHEL 9
Install PHP 8.4 in RHEL 9

Once installed, you can verify the PHP installation.

php -v
Verify PHP 8.4 in RHEL 9
Verify PHP 8.4 in RHEL 9

Step 5: Install Additional PHP Extensions (Optional)

Depending on your project requirements, you may need to install additional PHP extensions.

sudo dnf search php-*
Search for PHP Extensions
Search for PHP Extensions

Next, install the desired extensions using:

sudo dnf install php-gd php-xml
Install PHP Extensions in RHEL
Install PHP Extensions in RHEL

If you’re using Apache or Nginx as your web server, restart it to apply the changes.

sudo systemctl restart httpd
Or
sudo systemctl restart nginx

Lastly, below is a list of useful PHP articles that you can read for additional information:

You have successfully installed PHP 8.4 on your RHEL 9 system. You can now start developing or hosting web applications using the latest PHP version, taking advantage of its new features and enhancements.

Similar Posts