How to Install PHP 7.X in CentOS Stream 10

This guide explains how to install PHP 7.4 on CentOS Stream 10 using the EPEL and Remi repositories, followed by installing PHP 7.4.

Enable the EPEL Repository:

The EPEL (Extra Packages for Enterprise Linux) repository contains extra packages not available in the official CentOS repositories.

Run the following command to install EPEL:

dnf install -y epel-release

Output:

CentOS Stream 10 - BaseOS                                                                                                                                    4.2 MB/s | 6.3 MB     00:01
CentOS Stream 10 - AppStream                                                                                                                                 1.7 MB/s | 2.7 MB     00:01
CentOS Stream 10 - Extras packages                                                                                                                           7.9 kB/s | 3.8 kB     00:00
Dependencies resolved.
=============================================================================================================================================================================================
 Package                                        Architecture                             Version                                       Repository                                       Size
=============================================================================================================================================================================================
Installing:
 epel-release                                   noarch                                   10-2.el10s                                    extras-common                                    18 k

Transaction Summary
=============================================================================================================================================================================================
Install  1 Package

Total download size: 18 k
Installed size: 25 k
Downloading Packages:
epel-release-10-2.el10s.noarch.rpm                                                                                                                           188 kB/s |  18 kB     00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         63 kB/s |  18 kB     00:00
CentOS Stream 10 - Extras packages                                                                                                                           2.1 MB/s | 2.1 kB     00:00
Importing GPG key 0x1D997668:
 Userid     : "CentOS Extras SIG (https://wiki.centos.org/SpecialInterestGroup) <security@centos.org>"
 Fingerprint: 363F C097 2F64 B699 AED3 968E 1FF6 A217 1D99 7668
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
warning: Certificate 1FF6A2171D997668:

Install the Remi Repository:

The Remi repository provides newer versions of PHP. To install the Remi repository for CentOS Stream 10, run:

dnf install -y https://rpms.remirepo.net/enterprise/remi-release-10.rpm

Output:

[root@server ~]# dnf install -y https://rpms.remirepo.net/enterprise/remi-release-10.rpm
Extra Packages for Enterprise Linux 10 - x86_64                                                                                                              9.2 MB/s | 3.5 MB     00:00
Last metadata expiration check: 0:00:02 ago on Thu 20 Feb 2025 12:10:40 PM CST.
remi-release-10.rpm                                                                                                                                           62 kB/s |  32 kB     00:00
Dependencies resolved.
=============================================================================================================================================================================================
 Package                                       Architecture                            Version                                           Repository                                     Size
=============================================================================================================================================================================================
Installing:
 remi-release                                  noarch                                  10.0-2.el10.remi                                  @commandline                                   32 k

Transaction Summary
=============================================================================================================================================================================================
Install  1 Package

Total size: 32 k
Installed size: 34 k

Enable the Remi PHP 7.4 Module:

Now, enable the Remi PHP 7.4 module to make PHP 7.4 available for installation:

dnf module enable php:remi-7.4 -y

Output:

[root@server ~]# dnf module enable php:remi-7.4 -y
Remi's Modular repository for Enterprise Linux 10 - x86_64                                                                                                   158 kB/s | 191 kB     00:01
Safe Remi's RPM repository for Enterprise Linux 10 - x86_64                                                                                                  258 kB/s | 335 kB     00:01
Dependencies resolved.
=============================================================================================================================================================================================
 Package                                      Architecture                                Version                                         Repository                                    Size
=============================================================================================================================================================================================
Enabling module streams:
 php                                                                                      remi-7.4

Transaction Summary

Install PHP 7.4:

Once the repository is enabled, you can now install PHP 7.4 and some common PHP packages:

dnf install -y php php-cli php-fpm php-mysqlnd

Output:

Last metadata expiration check: 0:01:15 ago on Mon 17 Feb 2025 01:24:45 PM CST.
Dependencies resolved.
================================================================================
 Package          Arch   Version           Repository           Size
================================================================================
Installing:
 php              x86_64 7.4.27-1.el9     remi-php74           2.1 M
 php-cli          x86_64 7.4.27-1.el9     remi-php74           3.2 M
 php-fpm          x86_64 7.4.27-1.el9     remi-php74           1.2 M
 php-mysqlnd      x86_64 7.4.27-1.el9     remi-php74           226 k

Transaction Summary
================================================================================
Install  4 Packages

Total download size: 6.8 M
Installed size: 21 M

Verify the PHP Installation:

After the installation is complete, you can verify the version of PHP by running the following command:

php -v

Output:

[root@server ~]# php -v
PHP 7.4.33 (cli) (built: Nov 27 2024 15:59:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

You have successfully installed PHP 7.4 on CentOS Stream 10 using the EPEL and Remi repositories. You can now begin using PHP 7.4 for your web development projects.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS