How to Install PHP 8.x in CentOS 10 Stream
PHP is a popular scripting language used primarily for web development. To install PHP 8.x on CentOS 10 Stream, we need to enable the EPEL and Remi repositories, which contain the latest PHP packages.
Pre-requisites
- A system with CentOS 10 Stream installed and running.
- Root access to the system.
Update Your System
Before installing PHP, ensure your system is up-to-date by running the following command:
dnf update -y
Output:
[root@server ~]# dnf update -y
CentOS Stream 10 - BaseOS 7.4 MB/s | 6.3 MB 00:00
CentOS Stream 10 - AppStream 4.2 MB/s | 2.7 MB 00:00
CentOS Stream 10 - Extras packages 11 kB/s | 3.8 kB 00:00
Last metadata expiration check: 0:00:01 ago on Fri 21 Feb 2025 08:14:34 AM CST.
Dependencies resolved.
Nothing to do.
Complete!
Install the EPEL and Remi Repositories
PHP 8.x is available in the Remi repository, which requires the EPEL repository as a dependency.
First, install the EPEL repository:
sudo dnf install -y epel-release
Output:
[root@server ~]# sudo dnf install -y epel-release
Last metadata expiration check: 0:07:26 ago on Fri 21 Feb 2025 08:14:34 AM CST.
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 104 kB/s | 18 kB 00:00
--------------------------------------------------------------------------------
Total 51 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:
Policy rejects subkey 8B5C8111FCA5D0FF: Policy rejected non-revocation signatu re (PrimaryKeyBinding) requiring second pre-image resistance
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : epel-release-10-2.el10s.noarch 1/1
Running scriptlet: epel-release-10-2.el10s.noarch 1/1
Many EPEL packages require the CodeReady Builder (CRB) repository.
It is recommended that you run /usr/bin/crb enable to enable the CRB repository.
Installed:
epel-release-10-2.el10s.noarch
Next, install the Remi repository:
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-10.rpm
Output:
[root@server ~]# sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-10.rpm
Extra Packages for Enterprise Linux 10 - x86_64 3.6 MB/s | 3.5 MB 00:00
Last metadata expiration check: 0:00:03 ago on Fri 21 Feb 2025 08:28:26 AM CST.
remi-release-10.rpm 60 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
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : remi-release-10.0-2.el10.remi.noarch 1/1
Installed:
remi-release-10.0-2.el10.remi.noarch
Complete!
Verify Installed Repositories
You can check if the repositories are added successfully by running:
dnf repolist
Output:
[root@server ~]# dnf repolist
repo id repo name
appstream CentOS Stream 10 - AppStream
baseos CentOS Stream 10 - BaseOS
epel Extra Packages for Enterprise Linux 10 - x86_64
extras-common CentOS Stream 10 - Extras packages
remi-modular Remi's Modular repository for Enterprise Linux 10 - x86_64
remi-safe Safe Remi's RPM repository for Enterprise Linux 10 - x86_64
List Available PHP Modules
To check available PHP versions from the enabled repositories, use:
dnf module list php
Output:
[root@server ~]# dnf module list php
Remi's Modular repository for Enterprise Linux 10 - x86_64 164 kB/s | 191 kB 00:01
Safe Remi's RPM repository for Enterprise Linux 10 - x86_64 258 kB/s | 335 kB 00:01
Remi's Modular repository for Enterprise Linux 10 - x86_64
Name Stream Profiles Summary
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
php remi-8.1 common [d], devel, minimal PHP scripting language
php remi-8.2 common [d], devel, minimal PHP scripting language
php remi-8.3 common [d], devel, minimal PHP scripting language
php remi-8.4 common [d], devel, minimal PHP scripting language
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Enable PHP 8.x Module
Choose the latest PHP version available (e.g., PHP 8.3) and enable it:
sudo dnf module enable php:remi-8.3 -y
Output:
[root@server ~]# sudo dnf module enable php:remi-8.3 -y
Last metadata expiration check: 0:01:39 ago on Fri 21 Feb 2025 08:33:37 AM CST.
Dependencies resolved.
=============================================================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================================================
Enabling module streams:
php remi-8.3
Transaction Summary
=============================================================================================================================================================================================
Complete!
Install PHP 8.x and Extensions
Now, install PHP and commonly used extensions:
sudo dnf install -y php php-cli php-fpm php-mysqlnd php-zip php-devel \
php-mbstring php-xml php-curl php-bcmath php-json php-opcache php-pdo
Output:
[root@server ~]# sudo dnf install -y php php-cli php-fpm php-mysqlnd php-zip php-devel \
php-mbstring php-xml php-curl php-bcmath php-json php-opcache php-pdo
Last metadata expiration check: 0:03:35 ago on Fri 21 Feb 2025 08:33:37 AM CST.
Dependencies resolved.
=============================================================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================================================
Installing:
php x86_64 8.3.17-1.el10.remi remi-modular 1.8 M
php-bcmath x86_64 8.3.17-1.el10.remi remi-modular 39 k
php-cli x86_64 8.3.17-1.el10.remi remi-modular 2.2 M
php-common x86_64 8.3.17-1.el10.remi remi-modular 705 k
php-devel x86_64 8.3.17-1.el10.remi remi-modular 722 k
php-fpm x86_64 8.3.17-1.el10.remi remi-modular 1.9 M
php-mbstring x86_64 8.3.17-1.el10.remi remi-modular 524 k
php-mysqlnd x86_64 8.3.17-1.el10.remi remi-modular 144 k
php-opcache x86_64 8.3.17-1.el10.remi remi-modular 368 k
php-pdo x86_64 8.3.17-1.el10.remi remi-modular 90 k
php-pecl-zip x86_64 1.22.5-1.el10.remi.8.3 remi-modular 60 k
php-xml x86_64 8.3.17-1.el10.remi remi-modular 152 k
Installing dependencies:
Verify the Installation
After installation, confirm the installed PHP version:
php -v
Output:
[root@server ~]# php -v
PHP 8.3.17 (cli) (built: Feb 11 2025 22:03:03) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.17, Copyright (c) Zend Technologies
with Zend OPcache v8.3.17, Copyright (c), by Zend Technologies
PHP 8.x is now successfully installed on your CentOS 10 Stream system! 🚀
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