CentOS 8 is the latest release available for CentOS operating system. Our previous tutorial has the instructions for the installation of Apache on CentOS 8. This tutorial will help you to install PHP 7 on CentOS 8 and RHEL 8 Linux systems. PHP 7.4 is the latest stable version available for the installation.

Advertisement

Setup Yum Repository

For this tutorial, we will use the REMI repository for PHP installation on CentOS 8 Linux system. So add the REMI repository on your system using the following command.

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

REMI repository contains the PHP packages. You just need to enable the correct repo for the required PHP version. Find out the available repository for the different PHP versions.

sudo dnf module list php

Last metadata expiration check: 0:33:48 ago on Wed 23 Nov 2019 08:12:31 PM PST.
CentOS-8 - AppStream
Name      Stream             Profiles                          Summary
php       7.2 [d]            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 [e]       common [d] [i], devel, minimal    PHP scripting language
php       remi-7.4           common [d], devel, minimal        PHP scripting language

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

The above output shows that the default AppStream contains PHP 7.2 and REMI contains PHP 7.2, 7.3 and 7.4 packages. Let’s start with the PHP installation.

Install PHP on CentOS 8

At this point, your system is ready for PHP installation. PHP 7.4 is the latest stable release available for the installation. So you can use the latest version for the production servers. You can use other PHP versions as per your requirements.

Install PHP 7.4

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

Install PHP 7.3

sudo dnf module reset php
sudo dnf module enable php:remi-7.3
sudo dnf install php

Install PHP 7.2

sudo dnf module reset php
sudo dnf module enable php:remi-7.2
sudo dnf install php

Install PHP Modules

You may also require additional PHP modules to run your PHP application.

sudo dnf install php-gd php-mysqlnd php-soap

Test PHP Version

After successful installation use the following command to test the installed PHP version.

php -v

PHP 7.4.8 (cli) (built: Jul  9 2020 08:57:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies
Share.
Leave A Reply

Exit mobile version