This tutorial will help you to install PHP on CentOS 8 and RHEL 8 Linux systems. PHP 7.3 is the latest stable version available for installation and PHP 7.4 is in the release cycle.
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 still under development, so we don’t recommend to use for production servers. But still, you can use this on your development systems.
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 succesfull installation use the followign command to test the installed PHP version.
php -v PHP 7.3.12 (cli) (built: Nov 19 2019 10:24:51) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.12, Copyright (c) 1999-2018, by Zend Technologies
Leave a Reply