How to Install PHP 8.0 on Rocky Linux and AlmaLinux

PHP 8.0 was officially released back on November 26, 2020, and is a major update to PHP 7.4. At the time of publishing this guide, the latest stable release is PHP 8.0.8, which was released on July 1, 2021.

PHP 8.0 provides some groundbreaking optimizations and features which include:

  • Match expressions
  • Nullsafe operator
  • Union Types
  • Named arguments
  • Inheritance with private methods
  • Trailing comma in parameter lists
  • Weak Maps
  • Attributes version 2

And so much more…

In this brief tutorial, we will walk you through the installation of PHP 8.0 on Rocky Linux 8.

Step 1: Enable Remi Repository on Rocky Linux

PHP 8.0 is not yet available or present in Rocky Linux AppStream repositories. For this reason, we will install PHP 8.0 from the Remi repository which is a free third-party YUM repository that provides PHP stacks.

Right off the bat, install the EPEL repository (Extra Packages for Enterprise Linux) which provides access to commonly used software packages for Enterprise Linux.

To install the EPEL repository on Rocky Linux, run the command.

$ sudo dnf install epel-release

Once EPEL is installed, proceed and enable the Remi repository as provided.

$ sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
Enable Remi Repository on Rocky Linux
Enable Remi Repository on Rocky Linux

Step 2: Enable Remi Repository for PHP 8.0

PHP 7.4 is the default module on the Remi repository. This is indicated by the [d] tag. To list all the modules and confirm this, run the command:

$ sudo dnf module list php
List PHP Modules
List PHP Modules

To install PHP 8.0, we will first reset the default PHP module and enable the latest Remi PHP module which is Remi-8.0. So, run the commands below.

$ sudo dnf module reset php
$ sudo dnf module enable php:remi-8.0
Enable PHP Remi Module
Enable PHP Remi Module

Step 3: Install PHP 8.0 in Rocky Linux

Once Remi PHP 8.0 module is enabled, you can now install PHP 8.0 and commonly used PHP extensions as follows.

$ sudo dnf install php php-cli php-curl php-mysqlnd php-gd php-opcache php-zip php-intl
Install PHP on Rocky Linux
Install PHP on Rocky Linux

Once installed, confirm the version of PHP installed as follows.

$ php -v

From the output, we have managed to install the latest PHP release which is PHP 8.0.8.

Check PHP Version
Check PHP Version

And that’s pretty much it. We hope that you can now confidently install PHP 8.0 on Rocky Linux 8.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

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.

2 thoughts on “How to Install PHP 8.0 on Rocky Linux and AlmaLinux”

  1. This is very helpful but there is a typo:

    $ sudo dnf module list reset php
    

    This should be:

    $ sudo dnf module reset php
    
    Reply

Got something to say? Join the discussion.

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.