Installing PHP 8.2 on RHEL 9
I inherited a RHEL 9 box shipping PHP 8.0.27 — a version that reached end of life in November 2023, meaning no more security patches. In enterprise environments I have seen teams run EOL runtimes for months out of sheer inertia, and the risk compounds silently. I needed PHP 8.2 for framework compatibility and the performance gains from the maturing JIT compiler, so I upgraded through the Remi repository. Here is the procedure, step by step.
Why Upgrade to PHP 8.2?
PHP 8.2 brings several improvements over 8.0:
- Readonly classes - Declare entire classes as readonly
- Disjunctive Normal Form (DNF) Types - Combine union and intersection types
- null, false, and true as standalone types
- Random Extension - New object-oriented API for random number generation
- Deprecated dynamic properties - Better code quality enforcement
- Performance improvements - Continued optimisation from the JIT compiler
Prerequisites
Before proceeding, ensure you have:
- RHEL 9 with sudo access
- An active subscription or configured repositories
Step 1: Enable EPEL Repository
Extra Packages for Enterprise Linux (EPEL) is a Special Interest Group (SIG) from the Fedora Project that provides additional high-quality packages for RHEL and compatible distributions.
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y
Step 2: Enable Remi Repository
The Remi repository is maintained by Remi Collet, a Fedora packager. It provides the latest versions of PHP and related packages, making it the go-to source for PHP on RHEL-based systems.
sudo dnf install dnf-utils https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
Step 3: Install PHP 8.2
First, list available PHP module streams to see your options:
sudo dnf module list php
You’ll see multiple versions available from different repositories. Enable the Remi PHP 8.2 module:
sudo dnf module enable php:remi-8.2 -y
If you have an existing PHP installation, you may need to reset the module first:
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.2 -y
Now install PHP:
sudo dnf install php -y
Step 4: Install Common Extensions
You’ll likely need additional PHP extensions. Here are some commonly required ones:
sudo dnf install php-cli php-fpm php-mysqlnd php-pdo php-gd php-mbstring php-xml php-curl php-zip php-intl php-opcache -y
Step 5: Verify Installation
Confirm PHP 8.2 is installed correctly:
php -v
Expected output:
PHP 8.2.x (cli) (built: ...)
Copyright (c) The PHP Group
Zend Engine v4.2.x, Copyright (c) Zend Technologies
with Zend OPcache v8.2.x, ...
Check loaded modules:
php -m
Configuring PHP-FPM (Optional)
If you’re using PHP-FPM with Nginx or Apache:
# Start and enable PHP-FPM
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
# Check status
sudo systemctl status php-fpm
The main configuration file is located at /etc/php-fpm.d/www.conf.
Troubleshooting
Module conflicts: If you encounter conflicts with the default PHP module, reset it first:
sudo dnf module reset php
Missing extensions: Search for available extensions:
dnf search php- | grep 8.2
SELinux issues: If PHP-FPM fails to start, check SELinux:
sudo setsebool -P httpd_execmem 1
Final Thoughts
The procedure itself is straightforward — Remi Collet has done the thankless work of maintaining up-to-date packages for RHEL-based systems, and the community owes him a debt. What is less straightforward is the organisational discipline that comes after: updating composer.json constraints, running your test suite against the new runtime, and — if you are running PHP-FPM behind a reverse proxy — verifying that socket permissions and pool configurations survived the upgrade. I have been bitten by all three. The upgrade is the easy part; the vigilance that follows is what separates a healthy deployment from a time bomb.
Installing PHP 8.2 on RHEL 9
A step-by-step guide to upgrading PHP using the Remi repository.
Achraf SOLTANI — April 28, 2023
