How to Install PHP 7.4 on CentOS 8

PHP, a recursive acronym for PHP Hypertext Preprocessor, is a popular server-side scripting language used in web development for creating powerful and dynamic websites.

In this article, you will learn how to install PHP 7.4 on CentOS 8 Linux.

Step 1: Add EPEL and Remi Repositories

To get started, you need to add EPEL & Remi repository from where you will be able to install PHP 7.4 on CentOS 8 Linux.

To install and enable the EPEL repository on CentOS 8, execute the following dnf command.

# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Install EPEL Repo on CentOS 8
Install EPEL Repo on CentOS 8

To confirm the presence of the EPEL repository, run the following rpm command.

# rpm -qa | grep epel
Confirm EPEL Installation
Confirm EPEL Installation

Next, run the command below to add the Remi repository.

# dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Install Remi Repo on CentOS 8
Install Remi Repo on CentOS 8

Once again, to verify the existence of the Remi repository, run the command.

# rpm -qa | grep remi
Confirm Remi Repo Installation
Confirm Remi Repo Installation

Step 2: Install PHP 7.4 on CentOS 8

Upon successful addition of EPEL and Remi repositories, execute the command below to get a list of available PHP module streams.

# dnf module list php
List PHP Modules
List PHP Modules

From the output above, remi-7.4 is the latest PHP stream, and therefore we are going to enable the module stream as shown below.

# dnf module enable php:remi-7.4
Enable PHP Remi Stream
Enable PHP Remi Stream

Once the PHP remi-7.4 module has been enabled, you can then proceed and install PHP using the command below. This will also install a host of other packages such as Apache and Nginx modules.

# dnf install php php-cli php-common
Install PHP on CentOS 8
Install PHP on CentOS 8

To check the version of PHP installed, run the command.

# php -v
Verify PHP Installed Version
Verify PHP Installed Version

From the output, we can clearly see that we have installed PHP version 7.4! You can now proceed to test and deploy your applications using PHP. And that’s just about it for now. We do hope you found this guide helpful.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

3 thoughts on “How to Install PHP 7.4 on CentOS 8”

  1. Initially got this…

    $ dnf module enable php:remi-7.4
    
    Sample Output
    Last metadata expiration check: 0:00:46 ago on Thu 30 Jul 2020 03:45:19 AM UTC.
    Dependencies resolved.
    The operation would result in switching of module 'php' stream '7.2' to stream 'remi-7.4'
    Error: It is not possible to switch enabled streams of a module.
    

    It is recommended to remove all installed content from the module, and reset the module using ‘dnf module reset‘ command. After you reset the module, you can install the other stream.

    Reply

Leave a Reply to Nox Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.