How to Install PHP 8 on Rocky Linux 8

Install PHP 8 on Rocky Linux 8

In this article, we will have explained the necessary steps to install PHP 8 on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

PHP is a server-side scripting language, also known as a “Hypertext Preprocessor.” It is used for developing static and dynamic web applications. The new PHP contains many new features and optimizations, including named arguments, union types, attributes, constructor property promotion, match expression, null safe operators, JIT and improvements in the type system, error handling, and consistency.

Install PHP 8 on Rocky Linux 8

Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.

sudo dnf update
sudo dnf upgrade

Step 2. Add EPEL and REMI Repository.

To install the EPEL and REMI repository on Rocky Linux, run the command below:

sudo dnf install
sudo dnf install

Next, use the dnf command to update your repository list and use the list php command to see what options are available and the default:

sudo dnf update
sudo dnf module list php

Then, enable php:remi-8.0 module:

sudo dnf module enable php:remi-8.0

Step 2. Install PHP on the Rocky Linux system.

Run the command to install the latest PHP on our Rocky Linux system:

sudo dnf install php


[[email protected] ~]# sudo dnf install php
Last metadata expiration check: 0:00:46 ago on Mon 20 Sep 2021 10:36:44 PM EDT.
Dependencies resolved.
 Package              Architecture    Version                    Repository             Size
 php                  x86_64          8.0.6-1.el8.remi           remi-modular          1.6 M
Installing dependencies:
 libsodium            x86_64          1.0.18-2.el8               epel                  162 k
Installing weak dependencies:
 php-opcache          x86_64          8.0.6-1.el8.remi           remi-modular          762 k
 php-pdo              x86_64          8.0.6-1.el8.remi           remi-modular          154 k
 php-sodium           x86_64          8.0.6-1.el8.remi           remi-modular           93 k

Transaction Summary
Install  5 Packages

Total download size: 2.7 M
Installed size: 8.3 M
Is this ok [y/N]: y

If you would like to install the most commonly used extensions for PHP 8.0, use the following command below:

sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imap php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml

Check PHP version:

php -v


[[email protected] ~]# php -v
PHP 8.0.8 (cli) (built: Sept  10 2021 00:23:16) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies

That’s all you need to do to install PHP on Rocky Linux 8. I hope you find this quick tip helpful. For further reading on the Nginx web server, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.