How to Install PHP 7.X in CentOS 9 Stream

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

CentOS 9 Stream incorporates many applications and packages with recent versions. This is generally good because it allows us to take advantage of the new features they incorporate. However, there are times when we have to install previous versions of components such as PHP. So, in this post, you will learn how to install PHP 7.x on CentOS 9 Stream.

PHP is a web-oriented programming language. On CentOS 9 Stream version 8.1 is available, but there are times when we need an earlier version. In this sense, PHP 7.x still has some way to go, and many web applications require it.

Let’s get started.

Install PHP 7.x on CentOS 9

The first thing we need to do is to update the operating system completely.

sudo dnf update

Thereafter, you will need to enable the EPEL repository. After you do so, you will need to enable the REMI repository.

sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm 

Next, refresh DNF to import the GPG keys from the repository.

sudo dnf update --refresh

Now, in case a PHP installation already exists, we have to remove it from the system.

sudo dnf remove php php-fpm

And then the modules:

sudo dnf remove php*

Finally, we have to reset the PHP modules in DNF.

sudo dnf module list reset php

Then check how the PHP modules are now with the new repository loaded.

sudo dnf module list php
PHP modules on CentOS 9 Stream
PHP modules on CentOS 9 Stream

There you will see the available modules and also the PHP 7.4 module from REMI. Enable this module

sudo dnf module enable php:remi-7.4

Now install PHP as follows:

sudo dnf install php php-cli php-common
Install PHP 7.x on CentOS 9 Stream
Install PHP 7.x on CentOS 9 Stream

Verify the installed version

php -v
PHP 7.4.30 (cli) (built: Jun  7 2022 08:38:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies

So, PHP 7.x is installed on CentOS 9 Stream. Enjoy it!

Conclusion

In this post, you learned how to install an older version of PHP on CentOS 9. The process is simple to do and allows you to still have compatibility with applications that require it.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook