Install PHP 8 4 Rocky AlmaLinux

PHP 8.4 is not yet ready for production release but alpha releases are there for testing and sharing feedback with the development team. In this article we will install PHP 8.4 on Rocky Linux / AlmaLinux and the same process should apply for CentOS Stream flavors 9 or 8. In the last article we covered installation of PHP 8.4 on Ubuntu Linux. For the expected changes and features of PHP 8.4, check out the following links / resources:

It’s also a good practice to perform this installation on a newly provisioned instance of Rocky / AlmaLinux to avoid breaking you active system with applications serving live traffic.

Add EPEL and REMI repositories

First, we need to add EPEL and REMI repositories into the system.

  • Add EPEL repository
sudo dnf -y install epel-release
  • Install REMI repository
## EL 9-based systems ##
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm

## EL 8-based systems ##
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Validation can be done by listing available repositories in the system.

$ sudo dnf repolist
repo id                                                                                                            repo name
appstream                                                                                                          Rocky Linux 8 - AppStream
baseos                                                                                                             Rocky Linux 8 - BaseOS
epel                                                                                                               Extra Packages for Enterprise Linux 8 - x86_64
extras                                                                                                             Rocky Linux 8 - Extras
remi-modular                                                                                                       Remi's Modular repository for Enterprise Linux 8 - x86_64
remi-safe                                                                                                          Safe Remi's RPM repository for Enterprise Linux 8 - x86_64

You may be required to enable remi-safe repository which contain unstable software packages.

sudo dnf config-manager --set-enabled remi-safe

Install PHP 8.4 on Rocky / AlmaLinux / CentOS Stream

After the two repositories are added, the installation of PHP 8.4 can be done on your local system. To find out about the latest versions of PHP available in the system, run the following command:

sudo dnf module list php

Install PHP 8.4 by running the command below:

sudo dnf install php84

You will be prompted to accept installation, type y and press <ENTER>

Dependencies resolved.
===================================================================================================================================================================================================================================================================================
 Package                                                            Architecture                                          Version                                                                                   Repository                                                Size
===================================================================================================================================================================================================================================================================================
Installing:
 php84                                                              x86_64                                                8.4-1.el8.remi                                                                            remi-safe                                                8.0 k
Installing dependencies:
 capstone                                                           x86_64                                                4.0.2-5.el8                                                                               epel                                                     1.1 M
 environment-modules                                                x86_64                                                4.5.2-4.el8                                                                               baseos                                                   421 k
 httpd-filesystem                                                   noarch                                                2.4.37-65.module+el8.10.0+1840+b070a976.1                                                 appstream                                                 44 k
 libsodium                                                          x86_64                                                1.0.18-2.el8                                                                              epel                                                     162 k
 libxslt                                                            x86_64                                                1.1.32-6.el8                                                                              baseos                                                   249 k
 oniguruma5php                                                      x86_64                                                6.9.9-1.el8.remi                                                                          remi-safe                                                213 k
 php84-php-cli                                                      x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                3.9 M
 php84-php-common                                                   x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                785 k
 php84-runtime                                                      x86_64                                                8.4-1.el8.remi                                                                            remi-safe                                                1.1 M
 scl-utils                                                          x86_64                                                1:2.0.2-16.el8                                                                            appstream                                                 46 k
 tcl                                                                x86_64                                                1:8.6.8-2.el8                                                                             baseos                                                   1.1 M
Installing weak dependencies:
 php84-php-fpm                                                      x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                2.0 M
 php84-php-mbstring                                                 x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                553 k
 php84-php-opcache                                                  x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                529 k
 php84-php-pdo                                                      x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                159 k
 php84-php-sodium                                                   x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                104 k
 php84-php-xml                                                      x86_64                                                8.4.0~alpha4-1.el8.remi                                                                   remi-safe                                                889 k
Enabling module streams:
 httpd                                                                                                                    2.4

Transaction Summary
===================================================================================================================================================================================================================================================================================
Install  18 Packages

Total download size: 13 M
Installed size: 53 M
Is this ok [y/N]: y

Notice that this installation is from SCL and it is independent from your system, keeping the base OS safe. Few points to take note:

  • The installation is under the /opt/remi/php84 directory
  • Configuration files are placed inside the /etc/opt/remi/php84 directory

To get the version of PHP 8.4 installed, use the command:

$ php84 --version
PHP 8.4.0alpha4 (cli) (built: Aug  1 2024 00:50:38) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.4.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.0alpha4, Copyright (c), by Zend Technologies

Install PHP 8.4 Extensions

Use the commands below to install a PHP 8.4 extension.

sudo dnf install php84-<extension>

Let’s consider an example where we are installing mysqlnd and zip extensions.

sudo dnf install php84-php-mysqlnd php84-php-zip

To list listed modules run the following command:

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

[Zend Modules]
Zend OPcache

We will be updating this article when the official, stable version of PHP 8.4 is out. Stay tuned for updates.

LEAVE A REPLY

Please enter your comment!
Please enter your name here