How to Install PHP 7.X in CentOS Stream 9

PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites. It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.

Add Remi Repository

Remi, a third-party repository which offers multiple versions of PHP 7.X,

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

Install the Remi repository by using the below command,

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

List Available PHP module streams

Check the available PHP modules by using following command,

yum module list php

NOTE: In this example we are installing PHP 7.4.

Enable PHP:remi-7.4 module to install PHP 7.4

yum module enable php:remi-7.4 -y

Install PHP 7.4

Now that the PHP version has been set, we will install PHP by running the below command,

yum install -y php php-cli php-common

Check PHP Version

Once you have installed PHP, check the PHP version

php -v

This concludes our topic of installing php 7.4 on CentOS Stream 9 system.