Step 1: Add EPEL and REMI Repository

EPEL and REMI repositories are the main requirements for this installation. Add them to the system by running these commands:

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Step 2: Install PHP 7.4 on CentOS 8 / RHEL 8

Once the repositories are added, We can enable PHP 7.4 Remi module and install PHP 7.4 on CentOS 8 / RHEL 8

sudo dnf -y install dnf-utils

Enable the module stream for PHP 7.4 on CentOS 8 / RHEL 8.

sudo dnf module reset php -y
sudo dnf module install php:remi-7.4

se the next command to install additional packages:

sudo dnf update
sudo yum install php-xxx

The current PHP version should be 7.4.

$ php -v
PHP 7.4.0 (cli) (built: Nov 26 2019 20:13:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

To view enabled modules, run:

$ php --modules