How to Install PHP 8 in Rocky Linux 8

To add EPEL and REMI Repository.

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

To install yum utilities.

yum -y install yum-utils

To enable php 8 Remi repository.

yum module reset php

and

yum module install php:remi-8.0

Output:


[root@server ~]# yum module install php:remi-8.0
Last metadata expiration check: 0:00:17 ago on Mon 17 May 2021 10:36:44 PM EDT.
Dependencies resolved.
=============================================================================================
 Package            Arch     Version                                    Repository      Size
=============================================================================================
Installing group/module packages:
 php-cli            x86_64   8.0.6-1.el8.remi                           remi-modular   4.7 M
 php-common         x86_64   8.0.6-1.el8.remi                           remi-modular   1.2 M
 php-fpm            x86_64   8.0.6-1.el8.remi                           remi-modular   1.6 M
 php-mbstring       x86_64   8.0.6-1.el8.remi                           remi-modular   524 k
 php-xml            x86_64   8.0.6-1.el8.remi                           remi-modular   236 k
Installing dependencies:
 libxslt            x86_64   1.1.32-5.el8                               baseos         248 k
 oniguruma5php      x86_64   6.9.6-1.el8.remi                           remi-safe      208 k
Installing weak dependencies:
 nginx-filesystem   noarch   1:1.14.1-9.module+el8.3.0+121+6327f1ce     appstream       23 k
Installing module profiles:
 php/common
Enabling module streams:
 php                         remi-8.0

Transaction Summary
=============================================================================================
Install  8 Packages

.
.
.
.
Installed:
  libxslt-1.1.32-5.el8.x86_64
  nginx-filesystem-1:1.14.1-9.module+el8.3.0+121+6327f1ce.noarch
  oniguruma5php-6.9.6-1.el8.remi.x86_64
  php-cli-8.0.6-1.el8.remi.x86_64
  php-common-8.0.6-1.el8.remi.x86_64
  php-fpm-8.0.6-1.el8.remi.x86_64
  php-mbstring-8.0.6-1.el8.remi.x86_64
  php-xml-8.0.6-1.el8.remi.x86_64

Complete!

To install any remaining updates.

yum update

TO Install PHP 8

To install PHP.

yum install php

Output:

[root@server ~]# yum install php
Last metadata expiration check: 0:00:37 ago on Mon 17 May 2021 10:36:44 PM EDT.
Dependencies resolved.
=============================================================================================
 Package              Architecture    Version                    Repository             Size
=============================================================================================
Installing:
 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

.
.
.
.

Complete!

NOTE: It will prompt for permission type y and press Enter to proceed with the installation.

Check PHP Version.

php -v

Output:

[root@server ~]# php -v
PHP 8.0.6 (cli) (built: May  4 2021 17:26:18) ( 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

This concludes our topic of installing PHP 8 on the Rocky Linux 8 system.