PHP2Shell (CVE-2026-109618 / CVE-2026-109619) is a critical security problem in PHP itself that lets attackers take over web servers. Every website that runs PHP should be updated to 8.5.12, 8.4.27, 8.3.36, 8.2.35 or newer as soon as possible. Read our PHP2Shell check and patch guide.
Disclaimer: before attempting to update the PHP version of your website we would highly recommend that you make a full backup of it, just in case anything goes wrong.
This guide covers Red Hat Enterprise Linux (RHEL) and the distributions that are compatible with it, such as CentOS Stream, Rocky Linux, AlmaLinux and Oracle Linux, as well as Fedora. They all use the dnf package manager. The examples use PHP 8.4 on a release based on RHEL 9, so adjust the version numbers to match your own system.
CentOS Linux 7 and 8 have both reached their end of life and no longer receive any security updates, including updates for PHP. If your website still runs on one of them, upgrading PHP alone will not make the server safe. We strongly recommend moving to a supported system such as Rocky Linux, AlmaLinux or RHEL, and our guide to migrating a PHP website can help you plan the move.
Run the following command to see the PHP version used on the command line, and use our free PHP version checker to confirm the version your website is running.
php -v
Save a list of the installed PHP packages so that you can reinstall the same extensions after the upgrade:
rpm -qa 'php*' > ~/php-packages.txt
On RHEL 8 and 9 and their compatible distributions, the AppStream repository offers several PHP branches as separate module streams. Red Hat supports these streams for a set period, so this is the safest option when the branch you need is available. List the streams that your release offers:
sudo dnf module list php
Reset the current stream, enable the newer one and then synchronise the installed packages to it. Replace 8.3 with the newest stream shown in the list:
sudo dnf module reset php
sudo dnf module enable php:8.3
sudo dnf distro-sync
RHEL 10 and its compatible distributions no longer use module streams for PHP, so on those releases the packages are updated with a normal sudo dnf upgrade.
If your release does not offer the branch you need, the Remi repository is the most widely used alternative. It is run by Remi Collet, who also contributes to PHP packaging at Red Hat and Fedora. It depends on the EPEL repository, so install both first. Replace 9 with the major version of your release:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
On RHEL 8 and 9, enable the Remi module stream for the version you want and then install PHP with the extensions your site needs:
sudo dnf module reset php
sudo dnf module enable php:remi-8.4
sudo dnf install php php-cli php-fpm php-mysqlnd php-mbstring php-xml php-gd php-intl php-zip php-opcache
The repository's own configuration wizard at rpms.remirepo.net shows the exact commands for every release and PHP branch, including RHEL 10, so it is worth checking there if your system is not covered here.
Fedora moves quickly, and each release ships a recent PHP branch that is updated throughout its life. In most cases keeping Fedora up to date is enough:
sudo dnf upgrade --refresh
If you need a different branch from the one your Fedora release ships, upgrading to the next Fedora release is usually the simplest answer. The Remi repository also provides packages for Fedora, and its configuration wizard explains how to set them up.
On these distributions both Apache and Nginx normally run PHP through PHP-FPM. Restart PHP-FPM and your web server after the upgrade so that the new version is loaded:
sudo systemctl restart php-fpm
sudo systemctl restart httpd
If you use Nginx, restart nginx instead of httpd. Your settings are kept in /etc/php.ini and in the files inside /etc/php.d/, so check that any changes you made are still in place. If SELinux is enabled and the site stops working, the audit log in /var/log/audit/audit.log will usually show what has been blocked.
If your site shows errors after the upgrade, our guide to common PHP errors after upgrading explains the usual causes. It may also be time to call in a professional to assist, so check out our listings of PHP developers that can help upgrade or maintain your website.