How to Install PHP 7.3 in Rocky Linux 8

Add Remi Repository:

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

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

Install the Remi repository by using the below command

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

List the available PHP module stream:

To check list the available PHP module by using following command

yum module list php

Output:

[[email protected] ~]# yum module list php
Last metadata expiration check: 1:32:05 ago on Tue 18 May 2021 02:36:44 AM GMT.
Rocky Linux 8 - AppStream
Name       Stream             Profiles                            Summary
php        7.2 [d]            common [d], devel, minimal          PHP scripting language
php        7.3                common [d], devel, minimal          PHP scripting language
php        7.4                common [d], devel, minimal          PHP scripting language

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name       Stream             Profiles                            Summary
php        remi-7.2           common [d], devel, minimal          PHP scripting language
php        remi-7.3           common [d], devel, minimal          PHP scripting language
php        remi-7.4           common [d], devel, minimal          PHP scripting language
php        remi-8.0 [e]       common [d] [i], devel, minimal      PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Note: Here we can see the PHP version available in Rocky Linux 8 - AppStream and Remi [third-party repository]. Since the PHP 7.3 is available in both streams we can enable either one from it and install the PHP to the machine.

Enable php:remi-7.3 module to install PHP 7.3:

First, reset the PHP module

yum module reset php

And enable php 7.3 module to install.

yum module enable php:remi-7.3 -y

Output:

[[email protected] ~]# yum module enable php:remi-7.3 -y
Last metadata expiration check: 1:42:01 ago on Tue 18 May 2021 02:36:44 AM GMT.
Dependencies resolved.
=============================================================================================
 Package              Architecture        Version                 Repository            Size
=============================================================================================
Enabling module streams:
 php                                      remi-7.3

Transaction Summary
=============================================================================================

Complete!

Install PHP 7.3:

yum install -y php php-cli php-common

Check PHP Version:

Once you have installed PHP, check the PHP version

php -v

Output:

PHP 7.3 (cli) (built: May  4 2021 17:26:18) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies

Install PHP-FPM:

If you are setting up LEMP stack on Rocky Linux 8, you might want to install php-fpm 7.3

yum install -y php-fpm

Once you have installed PHP-FPM, check the PHP-FPM version

php-fpm -v

Output:

[[email protected] ~]# php-fpm -v
PHP 7.3 (fpm-fcgi) (built: May  4 2021 17:26:18)
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies