How to install PHP 8 on CentOS 7/RHEL and Oracle Linux

How to install PHP 8 on CentOS 7/RHEL and Oracle Linux

After installing Apache and Configuring Vhost you would install PHP and configure it to work with Apache so that you can use dynamic websites or CMS built with php such as Wordpress.

Install EPEL Repository

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

for CentOS/RHEL/Oracle Linux 7

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

for CentOS/RHEL/Oracle Linux 8

Verify if php8 is available:

yum list available | grep php8

Enable the respective Repository

yum-config-manager --enable remi-php81

for PHP8.1

yum-config-manager --enable remi-php80

for PHP8.0

Install php

yum install php -y

Verify php installation

php -v

Installing PHP Modules

yum install php-{extension-name}

For example to install php-fpm you would simply need to type:

yum install php-fpm -y