How to install PHP on CentOS 8

PHP scriptable programming language used for web development, interpretiruya on the server side. PHP is used in many modern Internet-resources that you use every day.

One of the innovations of PHP 7.4 can be distinguished: typed properties in classes, FFI for easy writing extensions for the language, functions-arrow keys to concise write single-line functions. In this article you will learn how to install PHP CentOS 8 the latest version at the moment is 7.4.

Install PHP in CentOS 7 8

First we need to install two repositories, EPEL and Remi.

1. Install EPEL

To install EPEL on CentOS 8, do:

sudo dnf install

To make sure that everything went well and EPEL are available, run:

rpm-qa | grep epel

2. Setting Remi

Then Remi installed:

sudo dnf install

Check the installation of Remi:

rpm-qa | grep remi

3. Install PHP

After a successful add EPEL and Remi, you need to choose the source from where we will install PHP. First we need to get a list of the sources of PHP:

dnf module list php

From the output you can see, the module is remi-7.4 with latest version available, we are going to connect:

sudo dnf module enable php:remi-7.4

After connecting the module php:remi-7.4, you can install PHP CentOS 8 command, which is given below, this will also install some packages such as php-fpm, Apache and nginx, as well as other dependencies for php:

sudo dnf install php php-cli php-common

If your system is already installed version of php, then it will be upgraded to version 7.4. In rare cases you will have to remove the conflicting dependencies. To check the version of PHP Centos 8, do:


From the output we can see that we have installed PHP version 7.4! Now you can test and run your PHP project.

How to remove php in CentOS

Let’s look at how to remove php centos 8 is installed in this way, it is enough to do:

sudo dnf remove php php-cli php-common

You can then disconnect a previously connected module php:remi:

sudo dnf remove module. php:remi-7.4

Then you can install centos php from the official repositories or connect another module. I hope you have had difficulties and this guide was useful for you.


(Visited 7 times, 1 visits today)