How to Install PHP 8.2 in AlmaLinux 9

PHP is a script language and interpreter that is freely available and used primarily on Linux Web servers.

To install PHP 8.2, we’ll need to add/enable the Remi RPM repositories which contain the PHP 8.2 packages that we need.

Pre-requisites :

  • A system with AlmaLinux 9 installed and running.

  • root access to the system.

First, let’s start by ensuring your system is up-to-date.

dnf update

Installing the EPEL and Remi Repository

For this, we use the PHP 8.2 packaged by Remi,

First, let us install the EPEL repository,

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

Next, install the Remi repository with the following command,

dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm

Output:

[root@vps ~]# dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Last metadata expiration check: 0:07:35 ago on Tue 13 Dec 2022 06:40:27 AM UTC.
remi-release-9.rpm                                                                                      34 kB/s |  25 kB     00:00
Dependencies resolved.
=======================================================================================================================================
 Package                          Architecture               Version                            Repository                        Size
=======================================================================================================================================
Installing:
 remi-release                     noarch                     9.0-6.el9.remi                     @commandline                      25 k
Installing dependencies:
 epel-release                     noarch                     9-2.el9                            extras                            17 k

Transaction Summary
=======================================================================================================================================
Install  2 Packages

List the available PHP module stream

To check/list the available PHP versions, use the following command,

dnf module list php

Output:

[root@vps ~]# dnf module list php
Extra Packages for Enterprise Linux 9 - x86_64                                                          15 MB/s |  12 MB     00:00
Remi's Modular repository for Enterprise Linux 9 - x86_64                                              810  B/s | 833  B     00:01
Remi's Modular repository for Enterprise Linux 9 - x86_64                                              3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0x478F8947:
 Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) <remi@remirepo.net>"
 Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
Is this ok [y/N]: y
Remi's Modular repository for Enterprise Linux 9 - x86_64                                              457 kB/s | 792 kB     00:01
Safe Remi's RPM repository for Enterprise Linux 9 - x86_64                                             909  B/s | 833  B     00:00
Safe Remi's RPM repository for Enterprise Linux 9 - x86_64                                             3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0x478F8947:
 Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) <remi@remirepo.net>"
 Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
Is this ok [y/N]: y
Safe Remi's RPM repository for Enterprise Linux 9 - x86_64                                             553 kB/s | 883 kB     00:01
Last metadata expiration check: 0:00:01 ago on Tue 13 Dec 2022 06:49:00 AM UTC.
AlmaLinux 9 - AppStream
Name                   Stream                     Profiles                                     Summary
php                    8.1                        common [d], devel, minimal                   PHP scripting language

Remi's Modular repository for Enterprise Linux 9 - x86_64
Name                   Stream                     Profiles                                     Summary
php                    remi-7.4                   common [d], devel, minimal                   PHP scripting language
php                    remi-8.0                   common [d], devel, minimal                   PHP scripting language
php                    remi-8.1                   common [d], devel, minimal                   PHP scripting language
php                    remi-8.2                   common [d], devel, minimal                   PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Installing PHP 8.2

Now, let's install PHP 8.2 via the remi repository,

dnf module install php:remi-8.2

Output:

[root@vps ~]# dnf module install php:remi-8.2
Last metadata expiration check: 0:00:36 ago on Tue 13 Dec 2022 06:49:00 AM UTC.
Dependencies resolved.
=======================================================================================================================================
 Package                           Architecture            Version                                 Repository                     Size
=======================================================================================================================================
Installing group/module packages:
 php-cli                           x86_64                  8.2.0-1.el9.remi                        remi-modular                  5.3 M
 php-common                        x86_64                  8.2.0-1.el9.remi                        remi-modular                  831 k
 php-fpm                           x86_64                  8.2.0-1.el9.remi                        remi-modular                  1.8 M
 php-mbstring                      x86_64                  8.2.0-1.el9.remi                        remi-modular                  574 k
 php-xml                           x86_64                  8.2.0-1.el9.remi                        remi-modular                  204 k
Installing dependencies:
 httpd-filesystem                  noarch                  2.4.53-7.el9                            appstream                      14 k
 libxslt                           x86_64                  1.1.34-9.el9                            appstream                     240 k
 oniguruma5php                     x86_64                  6.9.8-1.el9.remi                        remi-safe                     219 k
Installing weak dependencies:
 nginx-filesystem                  noarch                  1:1.20.1-13.el9.alma                    appstream                      11 k
Installing module profiles:
 php/common
Enabling module streams:
 php                                                       remi-8.2

Transaction Summary
=======================================================================================================================================
Install  9 Packages

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

You can update your system and install packages at any time by running the following command,

dnf update

Check Installed PHP Version

Now that we have installed PHP 8.2 via the remi repository, we can verify the version installed by running the php -v command,

php -v

Output:

[root@vps ~]# php -v
PHP 8.2.0 (cli) (built: Dec  6 2022 14:26:47) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies

This concludes our topic of installing PHP 8.2 on AlmaLinux 9 the system.