PHP 8.0 is a major update and release of the PHP programming language since version 7.4. PHP is a widely used programming language in development of websites and Web applications. Some of the most used website content management systems such as WordPress, Drupal and Joomla are written in PHP. This release of PHP comes with numerous improvements and new features such as:

  • Union Types
  • Named Arguments
  • Match Expressions
  • Attributes
  • Constructor Property Promotion
  • Nullsafe Operator
  • Weak Maps
  • Just In Time Compilation
  • And much much more…

In this short article we will be performing installation of PHP 8.0 on Rocky Linux 8 | AlmaLinux 8. PHP 8.0 packages are not available in OS AppStream repositories. We’ll need to add Remi RPM repositories to our AlmaLinux / Rocky OS which contains the packages that we need to install.

Add Remi YUM repository

Install and enable EPEL repository

sudo yum -y install epel-release

Also enable powertools repository:

sudo yum -y install yum-utils
sudo yum-config-manager --enable powertools

Add Remi repository to Rocky Linux 8 | AlmaLinux 8:

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

Install PHP 8.0 on Rocky Linux 8 | AlmaLinux 8

Reset PHP default module:

sudo dnf module reset php

Enable Remi repository for PHP 8.0

sudo yum module install php:remi-8.0

Confirm package dependencies and proceed with the installation:

Dependencies resolved.
==================================================================================================================================================================
 Package                            Architecture             Version                                                         Repository                      Size
==================================================================================================================================================================
Installing group/module packages:
 php-cli                            x86_64                   8.0.3-1.el8.remi                                                remi-modular                   4.7 M
 php-common                         x86_64                   8.0.3-1.el8.remi                                                remi-modular                   1.2 M
 php-fpm                            x86_64                   8.0.3-1.el8.remi                                                remi-modular                   1.6 M
 php-mbstring                       x86_64                   8.0.3-1.el8.remi                                                remi-modular                   523 k
 php-xml                            x86_64                   8.0.3-1.el8.remi                                                remi-modular                   236 k
Installing dependencies:
 httpd-filesystem                   noarch                   2.4.37-30.module_el8.3.0+2171+8bf57d29.alma.1                   appstream                       36 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+2165+af250afe.alma                    appstream                       23 k
Installing module profiles:
 php/common
Enabling module streams:
 httpd                                                       2.4
 nginx                                                       1.14
 php                                                         remi-8.0

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

Total download size: 8.6 M
Installed size: 43 M
Is this ok [y/N]: y

Import required repository key when asked:

------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                             908 kB/s | 8.6 MB     00:09
warning: /var/cache/dnf/remi-modular-6408ecca79e22107/packages/php-cli-8.0.3-1.el8.remi.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 5f11735a: NOKEY
Remi's Modular repository for Enterprise Linux 8 - x86_64                                                                         3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository <[email protected]>"
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y

To install additional packages use the command below:

sudo yum install php-xxx

Below example install PHP and commonly used PHP extensions:

sudo yum install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json

Proceed with the installation and confirm it is successful

Dependencies resolved.
==================================================================================================================================================================
 Package                               Architecture           Version                                                          Repository                    Size
==================================================================================================================================================================
Installing:
 php                                   x86_64                 8.0.3-1.el8.remi                                                 remi-modular                 1.6 M
 php-bcmath                            x86_64                 8.0.3-1.el8.remi                                                 remi-modular                  85 k
 php-devel                             x86_64                 8.0.3-1.el8.remi                                                 remi-modular                 1.2 M
 php-gd                                x86_64                 8.0.3-1.el8.remi                                                 remi-modular                 100 k
 php-mysqlnd                           x86_64                 8.0.3-1.el8.remi                                                 remi-modular                 260 k
 php-pear                              noarch                 1:1.10.12-5.el8.remi                                             remi-modular                 365 k
 php-pecl-mcrypt                       x86_64                 1.0.4-1.el8.remi.8.0                                             remi-modular                  34 k
 php-pecl-zip                          x86_64                 1.19.2-1.el8.remi.8.0                                            remi-modular                  71 k
Installing dependencies:
 almalinux-logos-httpd                 noarch                 81.2-1.el8                                                       appstream                     27 k
 apr                                   x86_64                 1.6.3-11.el8                                                     appstream                    124 k
 apr-util                              x86_64                 1.6.1-6.el8                                                      appstream                    105 k
 autoconf                              noarch                 2.69-27.el8                                                      appstream                    710 k
 automake                              noarch                 1.16.1-6.el8                                                     appstream                    713 k
 cmake-filesystem                      x86_64                 3.11.4-7.el8                                                     appstream                     40 k
 cpp                                   x86_64                 8.3.1-5.1.el8.alma                                               appstream                     10 M
 gcc                                   x86_64                 8.3.1-5.1.el8.alma                                               appstream                     23 M
 gcc-c++                               x86_64                 8.3.1-5.1.el8.alma                                               appstream                     12 M
 glibc-devel                           x86_64                 2.28-127.el8_3.2                                                 baseos                       1.0 M
 glibc-headers                         x86_64                 2.28-127.el8_3.2                                                 baseos                       475 k
 httpd                                 x86_64                 2.4.37-30.module_el8.3.0+2171+8bf57d29.alma.1                    appstream                    1.4 M
 httpd-tools                           x86_64                 2.4.37-30.module_el8.3.0+2171+8bf57d29.alma.1                    appstream                    103 k
 isl                                   x86_64                 0.16.1-6.el8                                                     appstream                    841 k
 kernel-headers                        x86_64                 4.18.0-240.22.1.el8_3                                            baseos                       5.6 M
 keyutils-libs-devel                   x86_64                 1.5.10-6.el8                                                     baseos                        48 k
 krb5-devel                            x86_64                 1.18.2-5.el8                                                     baseos                       558 k
 libcom_err-devel                      x86_64                 1.45.6-1.el8                                                     baseos                        38 k
 libkadm5                              x86_64                 1.18.2-5.el8                                                     baseos                       185 k
 libmcrypt                             x86_64                 2.5.8-26.el8                                                     epel                         109 k
 libselinux-devel                      x86_64                 2.9-4.el8_3                                                      baseos                       199 k
 libsepol-devel                        x86_64                 2.9-1.el8                                                        baseos                        85 k
 libsodium                             x86_64                 1.0.18-2.el8                                                     epel                         162 k
 libstdc++-devel                       x86_64                 8.3.1-5.1.el8.alma                                               appstream                    2.0 M
 libtool                               x86_64                 2.4.6-25.el8                                                     appstream                    708 k
 libverto-devel                        x86_64                 0.3.0-5.el8                                                      baseos                        18 k
 libxcrypt-devel                       x86_64                 4.1.1-4.el8                                                      baseos                        25 k
 libxml2-devel                         x86_64                 2.9.7-8.el8                                                      appstream                    1.0 M
 libzip                                x86_64                 1.7.3-1.el8.remi                                                 remi-modular                  66 k
 m4                                    x86_64                 1.4.18-7.el8                                                     baseos                       222 k
 make                                  x86_64                 1:4.2.1-10.el8                                                   baseos                       498 k
 mod_http2                             x86_64                 1.15.7-2.module_el8.3.0+2016+8bf57d29                            appstream                    153 k
 openssl-devel                         x86_64                 1:1.1.1g-15.el8_3                                                baseos                       2.3 M
 pcre2-devel                           x86_64                 10.32-2.el8                                                      baseos                       604 k
 pcre2-utf16                           x86_64                 10.32-2.el8                                                      baseos                       228 k
 pcre2-utf32                           x86_64                 10.32-2.el8                                                      baseos                       220 k
 perl-Thread-Queue                     noarch                 3.13-1.el8                                                       appstream                     24 k
 php-fedora-autoloader                 noarch                 1.0.1-2.el8.remi                                                 remi-modular                  13 k
 php-pdo                               x86_64                 8.0.3-1.el8.remi                                                 remi-modular                 153 k
 php-process                           x86_64                 8.0.3-1.el8.remi                                                 remi-modular                 104 k
 xz-devel                              x86_64                 5.2.4-3.el8                                                      baseos                        62 k
 zlib-devel                            x86_64                 1.2.11-16.2.el8_3                                                baseos                        56 k
Installing weak dependencies:
 apr-util-bdb                          x86_64                 1.6.1-6.el8                                                      appstream                     24 k
 apr-util-openssl                      x86_64                 1.6.1-6.el8                                                      appstream                     27 k
 php-opcache                           x86_64                 8.0.3-1.el8.remi                                                 remi-modular                 762 k
 php-sodium                            x86_64                 8.0.3-1.el8.remi                                                 remi-modular                  93 k

Transaction Summary
==================================================================================================================================================================
Install  54 Packages

Total download size: 71 M
Installed size: 192 M
Is this ok [y/N]: y

Use the next commands to check the installed version:

$ php --version
PHP 8.0.3 (cli) (built: Mar  2 2021 16:37:06) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies

Checking all available PHP extensions:

$ php --modules
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Enjoy your applications development and hosting on Rocky Linux 8 | AlmaLinux 8 using PHP 8.0.

More guides on AlmaLinux / Rocky:

Install Docker CE on AlmaLinux / Rocky Linux 8

EPEL Repository on Rocky Linux / AlmaLinux OS 8