PHP still powers a large part of the web, from WordPress, Drupal and Magento to Laravel and Symfony applications. Red Hat Enterprise Linux 10 changed how PHP is packaged: the DNF modules of RHEL 9 are gone, the system ships PHP 8.3 by default, and PHP 8.4 comes as a separate set of packages. For PHP 8.5, early 8.6 builds or legacy versions, the Remi repository fills the gap.
This guide covers all three methods on RHEL 10, Rocky Linux 10, AlmaLinux 10 and CentOS Stream 10. You will also install extensions, connect PHP to Apache or Nginx through PHP-FPM, run several PHP versions side by side and switch between them. Still on version 9? Follow our PHP on RHEL 9 guide instead.
Last tested: November 2026 on RHEL 10.3, Rocky Linux 10.3, AlmaLinux 10.3 and CentOS Stream 10.
Which PHP Version Should You Install?
Each PHP branch gets two years of active support and then two more years of security-only fixes. This is where each branch stands as of November 2026, and where to get it on RHEL 10:
| Version | Security support until | Available from |
|---|---|---|
| PHP 8.6 | Dec 31, 2030 | Remi (release candidate builds for now) |
| PHP 8.5 | Dec 31, 2029 | Remi. Best choice for new projects |
| PHP 8.4 | Dec 31, 2028 | AppStream (php8.4 packages) or Remi |
| PHP 8.3 | Dec 31, 2027 | RHEL 10 default in AppStream, or Remi |
| PHP 8.2, 8.1, 8.0, 7.4 | Dec 31, 2026 or ended | Remi only. Legacy code only |
Use the AppStream packages (Option A or B) when PHP 8.3 or 8.4 is enough and you want packages supported by your distribution vendor. Use Remi (Option C) for PHP 8.5 and newer, or for versions older than 8.3. See the PHP release tracker for the latest point releases.
Prerequisites
- A system running RHEL 10, Rocky Linux 10, AlmaLinux 10 or CentOS Stream 10
- A user account with sudo privileges
- An internet connection (and an active subscription on RHEL)
- A CPU that supports x86-64-v3. RHEL 10 and Rocky Linux 10 require it; on older hardware, AlmaLinux 10 offers an x86_64_v2 build.
Step 1 of 8Update Your System
Update the installed packages before installing PHP:
sudo dnf update -y
If the update installed a new kernel, reboot before continuing.
Step 2 of 8Option A: Install the Default PHP 8.3
RHEL 10 ships PHP 8.3 in AppStream, with no module to enable. Install it directly:
sudo dnf install php php-cli php-fpm php-common -y
Unlike RHEL 9, where a plain dnf install php still gives you the end-of-life PHP 8.0, this installs a supported release. Continue with Step 3.
Step 2 of 8Option B: Install PHP 8.4 from AppStream
PHP 8.4 is in AppStream as well, as a separate set of packages with a php8.4- prefix. They install the same php command and php-fpm service as the default version, so only one of the two can be installed at a time:
sudo dnf install php8.4 php8.4-cli php8.4-fpm php8.4-common -y
If PHP 8.3 is already installed, dnf stops with “php8.4-cli conflicts with php-cli < 8.4“. Add --allowerasing to replace the 8.3 packages with their 8.4 versions in one step. Include the extensions you use, so they are replaced as well:
sudo dnf install --allowerasing php8.4 php8.4-cli php8.4-fpm php8.4-common php8.4-mysqlnd -y
Step 2 of 8Option C: Install PHP 8.5 or Older Versions from Remi
The Remi repository is maintained by Remi Collet, who also maintains PHP packaging in Fedora and RHEL. On RHEL 10 it provides every PHP version from 8.6 down to 7.4, and it brings back the familiar module streams through its own remi-modular repository. Remi depends on EPEL, and EPEL needs the CodeReady Builder (CRB) repository.
Enable EPEL and CRB for your distribution:
- Rocky Linux 10, AlmaLinux 10 and CentOS Stream 10:
sudo dnf install epel-release -ysudo dnf config-manager --set-enabled crb - RHEL 10:
sudo subscription-manager repos --enable codeready-builder-for-rhel-10-$(arch)-rpmssudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm -y
If dnf config-manager isn’t found, install it with sudo dnf install dnf-plugins-core -y. Then add Remi and list the PHP streams it provides:
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-10.rpm -ydnf module list php
You will see the streams remi-7.4 to remi-8.6. Enable the version you need and install it:
- PHP 8.5 (recommended)
sudo dnf module enable php:remi-8.5 -ysudo dnf install php php-cli php-fpm php-common -y - PHP 7.4 or another legacy branch
sudo dnf module enable php:remi-7.4 -ysudo dnf install php php-cli php-fpm php-common -y
The remi-8.6 stream currently ships release candidate builds; use it for testing until the final 8.6 packages land. If AppStream PHP is already installed, enabling a stream and running sudo dnf distro-sync -y replaces it (see switching versions below).
Step 3 of 8Verify the Installation
Check the installed version:
php -v
PHP 8.5.12 (cli) (built: Oct 19 2026 17:02:46) (NTS gcc x86_64)
With Option A you will see PHP 8.3.36, and with Option B PHP 8.4.27 (or newer point releases).
Step 4 of 8Install PHP Extensions
Extension package names depend on where PHP comes from. These commands install the set that WordPress, Laravel, Symfony and similar projects expect:
- Option A, AppStream PHP 8.3:
sudo dnf install php-{mysqlnd,pgsql,gd,mbstring,xml,intl,bcmath,soap,opcache} php-pecl-zip php-pecl-redis6 -y - Option B, AppStream PHP 8.4:
sudo dnf install php8.4-{mysqlnd,pgsql,gd,mbstring,xml,intl,bcmath,soap,opcache} php8.4-pecl-zip php8.4-pecl-redis6 -y - Option C, Remi:
sudo dnf install php-{mysqlnd,pgsql,gd,mbstring,xml,zip,intl,bcmath,soap} php-pecl-redis -y
Verify the loaded modules:
php -m
- In AppStream, zip and redis are packaged as PECL extensions (php-pecl-zip, php-pecl-redis6). Remi uses php-zip and php-pecl-redis.
- OPcache is a separate package for PHP 8.4 and older. In PHP 8.5 it is built in, so Remi’s 8.5 needs no extra package.
- Search for other extensions with dnf search php-pecl or dnf search php8.4-.
Step 5 of 8Use PHP with Apache or Nginx
Both web servers run PHP through PHP-FPM, and the php-fpm package already contains the configuration for both. This is the same for all three options.
Apache (httpd)
Install Apache if needed (see how to install Apache (httpd)), then start both services:
sudo dnf install httpd -ysudo systemctl enable --now php-fpm httpd
The file /etc/httpd/conf.d/php.conf passes .php files to the socket /run/php-fpm/www.sock. No further configuration is needed.
Nginx
sudo dnf install nginx -ysudo systemctl enable --now php-fpm nginx
PHP-FPM adds /etc/nginx/conf.d/php-fpm.conf (an upstream named php-fpm) and /etc/nginx/default.d/php.conf, which the default server already includes. Add the same include to your own server blocks:
server {
listen 80;
server_name example.com;
root /var/www/example.com;
index index.php index.html;
include /etc/nginx/default.d/*.conf;
}
The socket accepts both the apache and nginx users (listen.acl_users = apache,nginx in /etc/php-fpm.d/www.conf). Test and reload Nginx:
sudo nginx -tsudo systemctl reload nginx
Firewall and SELinux
sudo firewall-cmd --permanent --add-service={http,https}sudo firewall-cmd --reload
Keep SELinux enabled. If your application connects to a database on another server, allow it explicitly:
sudo setsebool -P httpd_can_network_connect_db 1
Step 6 of 8Run Multiple PHP Versions Side by Side
The AppStream packages and Remi’s module streams both give you one “main” PHP version. With Remi enabled (Option C, Step 2), you can add parallel versions with a prefix such as php85, php84 or php74. They install into /opt/remi and work next to any main version, including AppStream’s PHP 8.3:
sudo dnf install php85-php-cli php85-php-fpm php85-php-mysqlnd -yphp85 -vsudo systemctl enable --now php85-php-fpm
The parallel PHP-FPM listens on /var/opt/remi/php85/run/php-fpm/www.sock and reads its settings from /etc/opt/remi/php85/. Point a site at it with fastcgi_pass unix:/var/opt/remi/php85/run/php-fpm/www.sock; in Nginx, or a SetHandler "proxy:unix:/var/opt/remi/php85/run/php-fpm/www.sock|fcgi://localhost" line in an Apache virtual host.
Switch the Main PHP Version
With Remi installed, change the main version by resetting the module, enabling another stream and letting dnf replace the packages:
sudo dnf module reset php -ysudo dnf module enable php:remi-8.4 -ysudo dnf distro-sync -ysudo systemctl restart php-fpm
To go back to the AppStream PHP 8.3, run only the reset and the distro-sync. To move between AppStream 8.3 and 8.4 without Remi, use the --allowerasing command from Option B. Test your application after every switch.
Step 7 of 8Adjust php.ini Settings
The main PHP installation reads /etc/php.ini and the extension files in /etc/php.d/. Check which files are loaded and edit the main file:
php --inisudo nano /etc/php.ini
Sensible starting values for a typical web application:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120
date.timezone = UTC
Restart PHP-FPM so websites pick up the changes:
sudo systemctl restart php-fpm
Parallel versions have their own files, for example /etc/opt/remi/php85/php.ini and the php85-php-fpm service.
Step 8 of 8Test PHP in the Browser
Create a test file in the web root. Apache uses /var/www/html; the default Nginx server uses /usr/share/nginx/html:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Open http://your-server-ip/info.php in a browser. The page shows the PHP version, the Server API (FPM/FastCGI) and the loaded extensions. Delete the file afterwards, because it reveals details about your server:
sudo rm /var/www/html/info.php
Most PHP projects also need Composer. See how to install Composer on RHEL-based systems.
Uninstall PHP
Remove the PHP packages. With Remi, also reset the module stream:
sudo dnf remove 'php*' -ysudo dnf module reset php -y
Remove a parallel version separately, for example with sudo dnf remove 'php85-*' -y.
Troubleshooting
php8.4-cli conflicts with php-cli < 8.4
PHP 8.3 is installed, and the AppStream PHP 8.4 packages can’t sit next to it. Add --allowerasing to replace 8.3, as shown in Option B. To keep both versions, use a Remi parallel package such as php84-php-cli instead.
Error: No matching Modules to list
RHEL 10 has no DNF modules of its own, so dnf module list php only works after you install the Remi release package, which adds the remi-modular repository.
Unable to find a match: php-zip or php-pecl-redis
You are using the AppStream PHP, which names these extensions php-pecl-zip and php-pecl-redis6 (with a php8.4- prefix for PHP 8.4). See the commands in Step 4.
502 Bad Gateway or “File not found” with Nginx
Check that PHP-FPM runs (systemctl status php-fpm) and that your server block includes /etc/nginx/default.d/*.conf or points fastcgi_pass at the right socket. For sites outside /var/www or /usr/share/nginx, SELinux may block access; fix the context with sudo restorecon -Rv /path/to/site or label the path with semanage fcontext.
Conclusion
You now have PHP running on RHEL 10, Rocky Linux 10, AlmaLinux 10 or CentOS Stream 10. The default PHP 8.3 and the AppStream PHP 8.4 packages are the simplest, vendor-supported choice. Remi adds PHP 8.5, early 8.6 builds, legacy branches and parallel versions, so one server can host applications that need different PHP releases.
How did it make you feel?
