Updated: 22 October 2026 · Applies to: AlmaLinux 9 / Rocky Linux 9
CentOS 7 and 8 are end of life. This guide installs PHP 8 on AlmaLinux 9 / Rocky Linux 9, either from the distribution's module streams or from the Remi repository for other 8.x versions. If you're here for the 21 October 2026 PHP security advisory, the fixed versions are 8.5.12, 8.4.27, 8.3.36 and 8.2.35: see How to Fix the Critical PHP Security Vulnerabilities.
From AppStream
dnf module reset php dnf module enable php:8.3 dnf install php php-fpm php-cli php-mysqlnd php-xml php-mbstring php-gd php-intl php-opcache php-pecl-zip
From Remi, for another version
Remi carries PHP 8.2, 8.3, 8.4 and 8.5 on Enterprise Linux 9, confirmed on AlmaLinux 9 (dnf module list php lists remi-8.5 and even remi-8.6 as available streams). Check which streams your server can actually see before picking one:
dnf install epel-release https://rpms.remirepo.net/enterprise/remi-release-9.rpm dnf module list php
dnf module reset php && dnf module enable php:remi-8.4 dnf install php php-fpm php-cli php-mysqlnd
Apply
systemctl enable --now php-fpm systemctl restart httpd # or nginx php -v
Updating an existing PHP install
If PHP is already installed and you just need the latest version in your enabled stream, one command checks and updates it:
php -v && dnf update -y "php*"
Tip: Remi also offers parallel versions (php83-php-fpm, php84-php-fpm) if different sites need different PHP versions.