How to Install PHP 8 on CentOS – RHEL 8 or 7

1 Answer(s)

    Step 1: Enable EPEL and Remi Repository on CentOS/RHEL

    Right off the bat, you need to enable the EPEL repository on your system. EPEL, short for Extra Packages for Enterprise Linux, is an effort from the Fedora team that provides a set of additional packages that are not present by default on RHEL & CentOS.

    $ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm  [On CentOS/RHEL 8]
    $ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm  [On CentOS/RHEL 7]

    Remi repository is a third-party repository that provides a wide range of PHP versions for RedHat Enterprise Linux. To install the Remi repository, run the command:

    $ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm  [On CentOS/RHEL 8]
    $ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm  [On CentOS/RHEL 7]

    Step 2: Install PHP 8 on CentOS/RHEL

    Once the installation is complete, proceed and list the available php module streams as shown:

    $ sudo dnf module list php

    We need to enable this module before installing PHP 8.0. To enable php:remi-8.0, execute:

    $ sudo dnf module enable php:remi-8.0 -y
    

    Once enabled, install PHP 8.0 for Apache or Nginx web server as shown:

    Install PHP 8.0 for Apache

    To install PHP 8 on the installed Apache web server, run:

    $ sudo dnf install php php-cli php-common
    
    

    Step 3: Verify PHP 8.0 on CentOS/RHEL

    There are two ways that you can use to verify the PHP version. On command-line, issue the command.

    $ php -v
    
    Answered on August 29, 2021.
    Add Comment

    Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.