How to Install PHP 8.2 in CentOS Stream 9

PHP is a script language and interpreter that is freely available and used primarily on Linux Web servers.

To install PHP 8.2, we’ll need to add/enable the Remi RPM repositories which contain the PHP 8.2 packages that we need.

Pre-requisites :

  • A system with CentOS Stream 9 installed and running.

  • root access to the system.

Installing the EPEL and Remi Repository

For this, we use the PHP 8.2 packaged by Remi,

First, let us install the EPEL repository,

dnf config-manager --set-enabled crb dnf install epel-release epel-next-release

Output:


[root@vps ~]# dnf config-manager --set-enabled crb
[root@vps ~]# dnf install epel-release epel-next-release
Last metadata expiration check: 0:00:06 ago on Wed 21 May 2025 05:26:03 PM UTC.
Dependencies resolved.
================================================================================
 Package                 Architecture Version         Repository           Size
================================================================================
Installing:
 epel-next-release       noarch       9-7.el9         extras-common       8.1 k
 epel-release            noarch       9-7.el9         extras-common        19 k

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 27 k
Installed size: 29 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): epel-next-release-9-7.el9.noarch.rpm     265 kB/s | 8.1 kB     00:00
(2/2): epel-release-9-7.el9.noarch.rpm          449 kB/s |  19 kB     00:00
--------------------------------------------------------------------------------
Total                                            44 kB/s |  27 kB     00:00
CentOS Stream 9 - Extras packages               1.2 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
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : epel-release-9-7.el9.noarch                            1/2
  Running scriptlet: epel-release-9-7.el9.noarch                            1/2
Many EPEL packages require the CodeReady Builder (CRB) repository.
It is recommended that you run /usr/bin/crb enable to enable the CRB repository.

  Installing       : epel-next-release-9-7.el9.noarch                       2/2
  Running scriptlet: epel-next-release-9-7.el9.noarch                       2/2
  Verifying        : epel-next-release-9-7.el9.noarch                       1/2
  Verifying        : epel-release-9-7.el9.noarch                            2/2

Installed:
  epel-next-release-9-7.el9.noarch          epel-release-9-7.el9.noarch

Complete!

Next, install the Remi repository with the following command,

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

Output:

[root@vps ~]# dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm Last metadata expiration check: 0:06:37 ago on Sat 01 Jul 2023 06:50:00 PM UTC. remi-release-9.rpm 40 kB/s | 28 kB 00:00 Dependencies resolved

Package Architecture Version Repository Size

Installing: remi-release noarch 9.2-1.el9.remi @commandline 28 k

Transaction Summary

Install 1 Package

Total size: 28 k Installed size: 27 k Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : remi-release-9.2-1.el9.remi.noarch 1/1 Verifying : remi-release-9.2-1.el9.remi.noarch 1/1

Installed: remi-release-9.2-1.el9.remi.noarch

Complete!

To install yum utilities.

dnf -y install yum-utils

To enable php 8.2 Remi repository.

dnf module reset php

dnf module enable php:remi-8.2

Output:

[root@vps ~]# dnf module enable php:remi-8.2

Last metadata expiration check: 0:59:24 ago on Sat 01 Jul 2023 06:57:31 PM UTC. Dependencies resolved

Package Architecture Version Repository Size

Installing module profiles: php/common

Transaction Summary

Is this ok [y/N]: Y Complete!

To install any remaining updates.

dnf update

Install PHP 8.2

To install PHP.

dnf install php

Output:

[root@vps ~]# dnf install php Last metadata expiration check: 0:15:05 ago on Sat 01 Jul 2023 06:57:31 PM UTC. Dependencies resolved

Package Architecture Version Repository Size

Installing: php x86_64 8.2.7-2.el9.remi remi-modular 1.8 M Installing dependencies: apr x86_64 1.7.0-11.el9 appstream 123 k apr-util x86_64 1.6.1-20.el9 appstream 95 k apr-util-bdb x86_64 1.6.1-20.el9 appstream 14 k httpd-core x86_64 2.4.57-2.el9 appstream 1.5 M httpd-filesystem noarch 2.4.57-2.el9 appstream 15 k httpd-tools x86_64 2.4.57-2.el9 appstream 84 k libsodium x86_64 1.0.18-8.el9 epel 161 k libxslt x86_64 1.1.34-9.el9 appstream 243 k mailcap noarch 2.1.49-5.el9 baseos 33 k oniguruma5php x86_64 6.9.8-1.el9.remi remi-safe 219 k php-common x86_64 8.2.7-2.el9.remi remi-modular 838 k Installing weak dependencies: apr-util-openssl x86_64 1.6.1-20.el9 appstream 16 k nginx-filesystem noarch 1:1.22.1-2.el9 appstream 12 k php-cli x86_64 8.2.7-2.el9.remi remi-modular 5.3 M php-fpm x86_64 8.2.7-2.el9.remi remi-modular 1.8 M php-mbstring x86_64 8.2.7-2.el9.remi remi-modular 574 k php-opcache x86_64 8.2.7-2.el9.remi remi-modular 601 k php-pdo x86_64 8.2.7-2.el9.remi remi-modular 117 k php-sodium x86_64 8.2.7-2.el9.remi remi-modular 62 k php-xml x86_64 8.2.7-2.el9.remi remi-modular 203 k

Transaction Summary

Install 21 Packages

Total download size: 14 M Installed size: 67 M Is this ok [y/N]: Y Downloading Packages: (1/21): mailcap-2.1.49-5.el9.noarch.rpm 74 kB/s | 33 kB 00:00 (2/21): apr-util-1.6.1-20.el9.x86_64.rpm 210 kB/s | 95 kB 00:00 (3/21): apr-1.7.0-11.el9.x86_64.rpm 185 kB/s | 123 kB 00:00 (4/21): apr-util-bdb-1.6.1-20.el9.x86_64.rpm 54 kB/s | 14 kB 00:00 (5/21): apr-util-openssl-1.6.1-20.el9.x86_64.rpm 41 kB/s | 16 kB 00:00 (6/21): httpd-filesystem-2.4.57-2.el9.noarch.rpm 35 kB/s | 15 kB 00:00 (7/21): httpd-tools-2.4.57-2.el9.x86_64.rpm 199 kB/s | 84 kB 00:00 (8/2 Complete!

NOTE: It will prompt for permission type y and press Enter to proceed with the installation.

To check PHP Version.

php -v

Output:

[root@vps ~]# php -v
PHP 8.2.28 (cli) (built: Mar 11 2025 17:58:12) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.28, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.28, Copyright (c), by Zend Technologies

This concludes our topic of installing PHP 8.2 on CentOS Stream 9 the 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