How to Install PHP 8 on Linux RHEL 8/Oracle Linux 8

Learn how to easily install PHP 8 on Linux RHEL 8 or Oracle Linux 8 to leverage the latest features and enhancements of your PHP application.

Installing PHP 8 on Linux RHEL 8/Oracle Linux 8 is a straightforward process that allows you to leverage the power and capabilities of the latest PHP version on your Linux server. PHP 8 brings numerous enhancements and performance improvements, making it a desirable choice for developers and system administrators. This guide will walk you through the steps required to successfully install PHP 8 on Linux RHEL 8/Oracle Linux 8, ensuring that you can take advantage of its new features and optimizations.

Install PHP 8 on Linux

Prerequisites

Before we begin the installation process, make sure you have the following prerequisites:

  1. A Linux RHEL 8 or Oracle Linux 8 system with root access.
  2. Basic knowledge of the Linux command line.

Step 1: Updating the System

The first step is to update your system to ensure you have the latest packages and security updates. Open your terminal and execute the following command:

# sudo dnf update -y

This command will update your system and prompt you for confirmation before proceeding. Enter your password when prompted and wait for the update process to complete.

Step 2: Adding the EPEL Remi Repository

To install PHP 8, we need to add the EPEL and Remi repository, which provides the latest PHP packages for RHEL and Oracle Linux. Execute the following commands to add the repository:

# sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Step 3: List the available PHP options as below.

# dnf module list php

Install PHP 8 on Linux

Example :

# dnf module list php

Last metadata expiration check: 0:04:19 ago on Fri 07 Jul 2023 09:31:59 PM +08.
Oracle Linux 8 Application Stream (x86_64)
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
php             7.4                 common [d], devel, minimal            PHP scripting language
php             8.0                 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
php             remi-8.1            common [d], devel, minimal            PHP scripting language
php             remi-8.2            common [d], devel, minimal            PHP scripting language

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

Step 4: Now enable PHP 8.2 :

# sudo dnf module enable php:remi-8.2 -y

Example :

[root@oraclelinux ~]# sudo dnf module enable php:remi-8.2 -y
Last metadata expiration check: 0:08:49 ago on Fri 07 Jul 2023 09:31:59 PM +08.
Dependencies resolved.
===========================================================================================================
 Package                  Architecture            Version                   Repository                Size
===========================================================================================================
Enabling module streams:
 php                                              remi-8.2

Transaction Summary
===========================================================================================================

Complete!

Step 5: Installing PHP 8:

# sudo dnf install php -y
[root@oraclelinux ~]# sudo dnf install php -y
Last metadata expiration check: 0:10:10 ago on Fri 07 Jul 2023 09:31:59 PM +08.
Dependencies resolved.
===========================================================================================================
 Package              Arch     Version                                          Repository            Size
===========================================================================================================
Installing:
 php                  x86_64   8.2.8-1.el8.remi                                 remi-modular         1.8 M
Installing dependencies:
 apr                  x86_64   1.6.3-12.el8                                     ol8_appstream        129 k
 apr-util             x86_64   1.6.1-6.el8_8.1                                  ol8_appstream        105 k
 httpd                x86_64   2.4.37-56.0.1.module+el8.8.0+21057+13668aee.6    ol8_appstream        1.4 M
 httpd-filesystem     noarch   2.4.37-56.0.1.module+el8.8.0+21057+13668aee.6    ol8_appstream         43 k
 httpd-tools          x86_64   2.4.37-56.0.1.module+el8.8.0+21057+13668aee.6    ol8_appstream        110 k
 libsodium            x86_64   1.0.18-2.el8                                     ol8_developer_EPEL   163 k
 mailcap              noarch   2.1.48-3.el8                                     ol8_baseos_latest     39 k
 mod_http2            x86_64   1.15.7-8.module+el8.8.0+21057+13668aee.3         ol8_appstream        155 k
 oniguruma5php        x86_64   6.9.8-1.el8.remi                                 remi-safe            212 k
 oracle-logos-httpd   noarch   84.5-1.0.1.el8                                   ol8_baseos_latest     29 k
 php-common           x86_64   8.2.8-1.el8.remi                                 remi-modular         1.3 M
Installing weak dependencies:
 apr-util-bdb         x86_64   1.6.1-6.el8_8.1                                  ol8_appstream         25 k
 apr-util-openssl     x86_64   1.6.1-6.el8_8.1                                  ol8_appstream         27 k
 php-cli              x86_64   8.2.8-1.el8.remi                                 remi-modular         5.4 M
 php-fpm              x86_64   8.2.8-1.el8.remi                                 remi-modular         1.9 M
 php-mbstring         x86_64   8.2.8-1.el8.remi                                 remi-modular         580 k
 php-opcache          x86_64   8.2.8-1.el8.remi                                 remi-modular         638 k
 php-pdo              x86_64   8.2.8-1.el8.remi                                 remi-modular         168 k
 php-sodium           x86_64   8.2.8-1.el8.remi                                 remi-modular         107 k
 php-xml              x86_64   8.2.8-1.el8.remi                                 remi-modular         259 k

Transaction Summary
===========================================================================================================
Install  21 Packages

Total download size: 15 M
Installed size: 58 M
..
..

Step 6: Verify the installed PHP version on our system.

# php -v

Install PHP 8 on Linux

Conclusion

In conclusion, installing PHP 8 on Linux RHEL 8/Oracle Linux 8 is a relatively simple procedure that enables you to harness the benefits of the latest PHP version on your Linux server. By following the steps outlined in this guide, you can ensure a smooth installation process and seamlessly transition to PHP 8. With its improved performance, enhanced features, and increased compatibility, PHP 8 provides an excellent platform for developing and deploying web applications. Stay up to date with the latest advancements in PHP by regularly checking for updates and security patches, as PHP continues to evolve and deliver even more powerful functionalities. Embrace the power of PHP 8 and unlock new possibilities for your web development projects on Linux RHEL 8/Oracle Linux 8.

Leave a Comment