On AlmaLinux, PHP can be installed from several sources, and the choice depends on which version you require. This article outlines the options available on AlmaLinux 10 and 9, the extensions and the configuration of PHP-FPM. The articles on installing Apache and PHP-FPM with a web server and virtual host, and on installing the Nginx mainline, provide further details.
We tested these steps in October 2026 on AlmaLinux 10.2 and 9.8; the version numbers were current at the time of testing. Run the commands as the root user or using sudo.
Which version of PHP comes with the system?
| System | Default | Other versions in the system’s repositories |
|---|---|---|
| AlmaLinux 10 | PHP 8.3 (8.3.36) | PHP 8.4 (8.4.27) is available as a separate package named php8.4, from version 10.2 onwards |
| AlmaLinux 9 | PHP 8.0 (8.0.30) | PHP 8.1, 8.2 and 8.3 as modules |
If you need PHP 8.5 or a version not listed here, you will need to use the Remi repository (see option 4). Our blog post explains which version is recommended for WordPress.
Only one version of the php package can be installed on a server at any one time. If you wish to run multiple versions simultaneously, you can do so using Remi’s phpXY packages.
Option 1: the default PHP
On AlmaLinux 10, this is PHP 8.3, which is patched by system updates throughout its entire lifecycle:
sudo dnf install php php-cli php-fpm php-mysqlnd php-gd php-xml php-mbstring php-intl php-opcache php-pecl-zip
php -v
The first line of the php -v command is: PHP 8.3.36 (cli). On AlmaLinux 9, the same command would install PHP 8.0, which is no longer supported by the PHP developers; in that case, select from the available modules (option 3).
Option 2: PHP 8.4 on AlmaLinux 10, from the system repository
Since Red Hat Enterprise Linux 10.2 (see the Red Hat release notes), and consequently since AlmaLinux 10.2, PHP 8.4 has also been available in the AppStream repository as packages prefixed with php8.4- (php8.4-cli, php8.4-fpm, php8.4-mysqlnd, php8.4-gd, php8.4-intl, php8.4-mbstring, php8.4-xml, php8.4-opcache, php8.4-pecl-zip, php8.4-pecl-redis6, php8.4-pecl-apcu and others). If you are on an earlier version of the 10 series, update the system first (sudo dnf upgrade); the release number is shown by cat /etc/almalinux-release. The list of packages:
dnf list --available 'php8.4*'
Install them easily on a fresh system:
sudo dnf install php8.4-cli php8.4-fpm php8.4-mysqlnd php8.4-gd php8.4-xml php8.4-mbstring php8.4-intl php8.4-opcache
If PHP 8.3 is already running, the installation will fail due to a conflict: “package php8.4-fpm … conflicts with php-fpm < 8.4”. The two versions cannot be installed simultaneously; version 8.4 will replace version 8.3. To carry out the replacement, allow dnf-nek to remove the old packages:
sudo dnf install --allowerasing php8.4-cli php8.4-fpm php8.4-mysqlnd
In the test, dnf removed the php-common and php-fpm version 8.3 packages (Removing dependent packages). Specify the php8.4- equivalent for every version 8.3 extension package in the command, otherwise they will be removed during the upgrade.
After the change:
- The command remains
php, the service remainsphp-fpm, and the location of the settings remains unchanged; - The
php-fpmservice will be disabled because its package has been reinstalled. Please re-enable it, otherwise it will not start after the next reboot:
sudo systemctl enable --now php-fpm
At the time of testing, the php8.4 package set did not include all the extensions available for 8.3 via EPEL (such as imagick). If your application requires these, please use the Remi repository.
Option 3: from another PHP module on AlmaLinux 9
On AlmaLinux 9, the available versions are listed by the dnf module list php command. Selecting and installing PHP 8.3:
sudo dnf module reset php
sudo dnf module enable php:8.3
sudo dnf install php php-cli php-fpm php-mysqlnd php-gd php-xml php-mbstring php-intl php-opcache php-pecl-zip
Option 4: PHP from the Remi repository
With the Remi repository, any version of PHP from 7.4 to 8.5 can be installed on both AlmaLinux 9 and 10 (at the time of testing, version 8.6 was available as a pre-release RC version). The procedure for setting up the repository is described in the article ‘Installing the Remi repository on AlmaLinux’; after that, for example, PHP 8.4:
sudo dnf module reset php
sudo dnf module enable php:remi-8.4
sudo dnf install php php-cli php-fpm php-mysqlnd php-gd php-xml php-mbstring php-intl php-opcache php-pecl-zip php-pecl-redis
php -v
PHP 8.4.27 (cli) (built: Oct 19 2026 14:38:59) (NTS gcc aarch64)
Copyright (c) The PHP Group
Built by Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine #NoAI
The line Built by Remi's RPM repository indicates that PHP comes from the Remi repository. For the package name php-pecl-redis, dnf installed the php-pecl-redis6 extension. You can later switch to a different version using the command sudo dnf module switch-to php:remi-8.5; this will also replace the installed extensions.
Plugins
The extensions are separate packages, prefixed with php- (or php8.4-). The lists above are sufficient for WordPress and most CMSs. Check:
php -m
dnf list --installed 'php*'
Frequently requested additional extensions: php-bcmath (precise calculations, e.g. in online shops), php-soap (SOAP APIs), php-pgsql (PostgreSQL), php-pecl-apcu (in-memory cache). To search for available extensions: dnf search php-pecl or dnf list --available 'php-pecl-*'. After installation, restart PHP-FPM (sudo systemctl restart php-fpm), otherwise the website will continue to run with the old list of extensions.
PHP-FPM
The PHP for the websites is run by the PHP-FPM service; the web server simply forwards requests to it. Start-up and automatic start-up:
sudo systemctl enable --now php-fpm
The key default settings are in the file /etc/php-fpm.d/www.conf:
user = apache
group = apache
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx
By default, PHP runs as the apache user and accepts requests via a Unix socket, which is accessible to both the apache and nginx users. This means that both Apache and Nginx can use it without the need for separate permission settings.
- Apache: the
php-fpmpackage is automatically loaded via the/etc/httpd/conf.d/php.conffile; you simply need to restarthttpd. - Nginx: PHP requests must be directed to the socket within the
serverblock; see the Nginx article.
The commonly configured settings (upload_max_filesize, memory_limit, pm.max_children) are listed in section 7 of the Apache and PHP-FPM article.
Check on the website
Create a test file in the web server’s root directory, open it, then delete it:
echo '<?php echo PHP_VERSION, " ", PHP_SAPI, "\n";' | sudo tee /var/www/html/v.php
curl -s http://localhost/v.php
sudo rm /var/www/html/v.php
In the test using Apache, the response was 8.5.12 fpm-fcgi: the fpm-fcgi part of the version number indicates that the request was served by PHP-FPM. If the PHP code is displayed in the browser or the file is downloaded, the web server is not connected to PHP-FPM.
Changing versions and reverting
Before upgrading, perform a backup of your website and database, and, if possible, test the application on a test environment to check that it works with the new version. On a VPS, the safest option is to take a snapshot before the upgrade. Rolling back:
- Remi module:
sudo dnf module switch-to php:remi-8.3(or whichever was running previously); - Reset the system’s PHP:
sudo dnf module reset php, followed bysudo dnf distro-sync. During the test, this replaced the Remi PHP 8.5 with AlmaLinux 10’s own 8.3.36 packages, including the extensions.
If you are unsure which module is selected, the command dnf module list php --enabled will show you (on AlmaLinux 10, there are no modules for the system’s PHP; only those from Remi may appear there).
Removing PHP
sudo systemctl disable --now php-fpm
sudo dnf remove 'php*'
sudo dnf module reset php
The 'php*' pattern removes all PHP packages and extensions, so on servers running multiple applications, please check the dnf list before confirming. This does not affect website files, the database or the web server.
If you do not wish to manage PHP versions via the command line, you can select the version and extensions in the control panel for cPanel hosting, whilst on KVM VPS you can configure any version by following the steps above.