
Unlock Modern PHP Versions on RHEL 9 & 8 with the Remi Repository
For developers and system administrators working with Red Hat Enterprise Linux (RHEL) and its derivatives like CentOS Stream, Rocky Linux, or AlmaLinux, a common challenge is the age of the software in the official repositories. While this focus on stability is a hallmark of enterprise systems, it can leave you with an older version of PHP that lacks modern features and performance improvements.
This is where the Remi repository comes in. It is a widely trusted, third-party repository that provides the latest versions of PHP and its related extensions, allowing you to bridge the gap between enterprise stability and modern development needs. This guide provides a clear, step-by-step process for enabling the Remi repository and installing an up-to-date PHP version on your system.
Why Choose the Remi Repository?
Before diving into the installation, it’s important to understand the benefits. The Remi repo isn’t just another third-party source; it’s a meticulously maintained resource with a strong reputation in the Linux community.
- Access to the Latest PHP Stacks: Gain immediate access to the newest stable PHP versions (like PHP 8.1, 8.2, 8.3, etc.) as soon as they are released and tested.
- Curated by an Expert: The repository is maintained by Remi Collet, a professional PHP contributor and package maintainer, ensuring high-quality, reliable packages.
- Comprehensive Software Collection: Beyond the PHP core, the repository offers a vast collection of updated extensions and related software like Redis and Memcached.
Prerequisite: Enable the EPEL Repository
The Remi repository depends on packages contained within the Extra Packages for Enterprise Linux (EPEL) repository. You must enable EPEL before proceeding. EPEL provides essential supplementary packages that are not included in the default RHEL repositories.
To install and enable EPEL, run the following command:
sudo dnf install epel-release -y
This command will install the configuration files needed for your system to access the EPEL repository.
Step 1: Install the Remi Repository Configuration
With EPEL enabled, you can now install the Remi repository. The installation package is specific to your operating system version.
For RHEL 9, CentOS Stream 9, Rocky Linux 9, or AlmaLinux 9:
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
For RHEL 8, CentOS Stream 8, Rocky Linux 8, or AlmaLinux 8:
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
After the installation completes, you can verify that the new repositories are available to your system’s package manager with this command:
dnf repolist | grep remi
You should see several Remi repositories listed, such as remi-safe and remi-modular.
Step 2: Enable the Desired PHP Version
One of the best features of the Remi repository is its use of modular streams. This allows you to choose exactly which version of PHP you want to install and makes it the system’s default.
First, list the available PHP module streams to see your options:
dnf module list php
The output will show you the various PHP versions available from the Remi repo (e.g., php:remi-8.1, php:remi-8.2).
To enable a specific version, use the dnf module enable command. For example, to set up your system to install PHP 8.2, you would run:
sudo dnf module enable php:remi-8.2 -y
The system will now prioritize PHP packages from the remi-8.2 stream whenever you use the dnf command.
Step 3: Install PHP and Common Extensions
Now that you’ve enabled the correct module, installing PHP is straightforward. You can install the main PHP package along with any common extensions you might need for a web application.
Here is a common command to install PHP-FPM for web server integration, the command-line interface (CLI), and popular extensions for database connectivity and image manipulation:
sudo dnf install php php-fpm php-cli php-mysqlnd php-gd php-xml php-mbstring php-json -y
This single command will install PHP 8.2 and its corresponding extensions because you enabled the remi-8.2 module in the previous step.
Step 4: Verify Your PHP Installation
Finally, confirm that the correct version of PHP has been successfully installed. Check the version from your command line:
php -v
The output should display the version you chose to install, confirming that your system is now running a modern, up-to-date PHP environment.
PHP 8.2.14 (cli) (built: Dec 19 2023 15:43:24) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.14, Copyright (c) Zend Technologies
Security and Best Practices
- Stick to Modular Streams: The modular approach (
dnf module enable ...) is the recommended and safest way to use the Remi repo. It prevents accidental upgrades and conflicts by explicitly defining which package versions your system should use. - Keep Your System Updated: Now that you have added new repositories, it’s crucial to run system updates regularly. This ensures you receive important security patches for PHP and all other system packages. Use
sudo dnf updateto keep everything current. - Install Only What You Need: While the Remi repository offers a vast number of packages, you should only install the PHP extensions your applications specifically require. This minimizes your server’s attack surface and reduces complexity.
Source: https://infotechys.com/enable-remi-repository-rhel-10/


