Upgrading to PHP 8.2 on RHEL/RockyLinux

This guide covers upgrading to PHP 8.2 on RHEL and Rocky Linux. The default PHP that ships in the base repositories is usually an older version, so the approach here is to pull PHP 8.2 from the REMI repository, which packages current PHP releases for enterprise Linux, and then install the modules a typical web application needs.

Step 1: Update the System First

Before adding any repositories, update the system so you’re working from a clean, fully patched base, then reboot so any kernel or core updates take effect:

sudo dnf update -y
sudo reboot

Step 2: Add the EPEL and REMI Repositories

REMI depends on EPEL (Extra Packages for Enterprise Linux), so install EPEL first, then the REMI release package. These examples are for version 8, so adjust the number if you’re on a different major release:

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

Then refresh the package cache so DNF picks up everything the new repositories offer:

sudo dnf makecache -y

Step 3: Switch to the PHP 8.2 Module

PHP is managed as a DNF module, so reset it first to clear whatever version is currently selected, then enable the REMI 8.2 stream and install PHP:

sudo dnf module reset php -y
sudo dnf module install php:remi-8.2 -y
sudo dnf -y install php

Confirm you’re now on 8.2:

php -v

Step 4: Install the PHP Modules You Need

Finally, install the extension modules. The list below covers what most web applications need, and the brace expansion lets you install them all in one command rather than one at a time. Trim it down to only what your application actually uses if you’d rather keep things lean:

sudo dnf install php-{ctype,dom,fileinfo,gd,openssl,posix,session,simplexml,xmlreader,xmlwriter,zlib,common,pear,cgi,curl,mbstring,mysqlnd,gettext,bcmath,xml,fpm,intl,zip,imap,bz2,ldap,smbclient,ftp,gmp,exif,imagick,pcntl,phar}

That’s the upgrade done. The steps are written for Rocky Linux 8, so if you’re on a different release just adjust the EPEL and REMI version numbers to match, and the rest of the process stays the same.

Related guides


Comments

3 responses to “Upgrading to PHP 8.2 on RHEL/RockyLinux”

  1. DanielCax Avatar

    Cryptocurrency in top terms. Best path to get prosperity.
    Just do it!

    1. You make a great point Daniel, I will be working on a post about crypto in the near future.

  2. Wonderful blog! I found it while surfing around on Yahoo
    News. Do you have any tips on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get there!
    Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *