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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

3 Comments

Leave a Reply
  1. Really great guide for upgrading the PHP version. Much appreciated!

    Pretty nifty with the module system too. I upgraded from PHP 7.3 to 8.3 following your guide.

    Thank you!

    Reply
  2. 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...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.