Upgrade PHP from 7.x to 8.x in RHEL8
Overview: This article helps Linux user to upgrade PHP from lower version to latest version(8.2) in Alma Linux, Rocky Linux and RHEL.
1. How to upgrade PHP from 7.x to 8.2 in AlmaLinux 8.x, RockyLinux 8.x, RHEL 8.x?
Step 1(A): Enable EPEL and Remi repositories, run the below command:
root@server:~# dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
Step 1(B):. Install the PHP 8.2 repository
root@server:~# dnf module reset php -y
root@server:~# dnf module install php:remi-8.2 -y
Step 1(C): Install yum-util packages
root@server:~# yum install yum-utils -y
Step 1(D): Then run the update command
root@server:~# yum update
Step 1(E): To verify that PHP 8.2 has been successfully installed, check the version by running the following command:
root@server:~# php -v
2. How to upgrade PHP from 7.x to 8.2 in AlmaLinux 9.x, RockyLinux 9.x, RHEL 9.x?
Step 2(A): Install the EPEL repository. Run the following command:
root@server:~# dnf install epel-release
Step 2(B): Install the Remi repository by executing the following command
root@server:~# dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm
Step 2(C): Install the DNF utilities
root@server:~# dnf install dnf-utils
Step 2(D): Enable the PHP 8.2 Remi repository, run the following commands:
root@server:~# dnf module reset php
root@server:~# dnf module install php:remi-8.2
Step 2(E): Run the following command to install PHP 8.2:
root@server:~# dnf install php
Step 2(F): Check the PHP version by running the following command:
root@server:~# php -v
2(A). How to upgrade PHP from 7.x to 8.4 in AlmaLinux 9.x, RockyLinux 9.x, RHEL 9.x?
Step 2(A): Install the EPEL repository. Run the following command:
root@server:~# dnf install epel-release
Step 2(B): Install the Remi repository by executing the following command
root@server:~# dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
Step 2(C): Install the DNF utilities
root@server:~# dnf install dnf-utils -y
Step 2(D): Enable the PHP 8.2 Remi repository, run the following commands:
root@server:~# dnf module reset php
root@server:~# dnf module install php:remi-8.4
Step 2(E): Run the following command to install PHP 8.4:
root@server:~# dnf install php
Step 2(F): Check the PHP version by running the following command:
root@server:~# php -v
PHP 8.4.13 (cli) (built: Oct 22 2026 11:01:00) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.4.13, Copyright (c) Zend Technologies
with Zend OPcache v8.4.13, Copyright (c), by Zend Technologies
3. How to upgrade PHP from 7.x to 8.2 in Oracle Linux 8?
Step 3(A): Install EPEL and Remi repos in Oracle Linux 8
root@server:~# dnf install -y oracle-epel-release-el8
root@server:~# dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Step 3(B): Reset existing PHP module and enable Remi's PHP 8.2
root@server:~# dnf module reset php -y
root@server:~# dnf module enable php:remi-8.2 -y
Step 3(C): Run the following command to install PHP 8.2:
root@server:~# dnf install php
Step 2(D): Check the PHP version by running the following command:
root@server:~# php -v
Related Articles:
GUI not working after PHP upgrade
Upgrade to php version 8.2 in OpenSUSE 15
