How to install or upgrade to PHP 8.3 on Rocky Linux 9.3

To Install Or Upgrade To PHP 8.3 On Rocky Linux 9.3

Introduction:

PHP 8.3 is a significant update to PHP released in 2023. This update includes a variety of new features such as typed class constants, enhanced Exceptions in the DateTime extension, the introduction of the json_validate function, as well as functional changes, improvements, and deprecations. Similar to previous major versions, PHP 8.3 will also address various bug fixes and performance enhancements.

Procedure:

Step 1: Check the OS version by using the below Command.

[root@linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.3"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.3"

Step 2: Add EPEL and REMI Repository by using the below command.

[root@linuxhelp ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
[root@linuxhelp ~]# dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.2.rpm

Step 3: Install yum utilities by using the below command.

[root@linuxhelp ~]# dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.2.rpm
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                         332 kB/s |  14 MB     00:41
Last metadata expiration check: 0:00:36 ago on Friday 10 May 2024 03:29:17 AM.
remi-release-9.2.rpm                                                                                                                                                    35 kB/s |  28 kB     00:00
Dependencies resolved.
=======================================================================================================================================================================================================
 Package                                          Architecture                               Version                                            Repository                                        Size
=======================================================================================================================================================================================================
Installing:
 remi-release                                     noarch                                     9.2-1.el9.remi                                     @commandline                                      28 k
Upgrading:
 epel-release                                     noarch                                     9-7.el9                                            extras                                            19 k

Transaction Summary
=======================================================================================================================================================================================================
Install  1 Package
Upgrade  1 Package

Total size: 46 k
Total download size: 19 k
Upgraded:
  dnf-plugins-core-4.3.0-13.el9.noarch                                                           python3-dnf-plugins-core-4.3.0-13.el9.noarch
Installed:
  yum-utils-4.3.0-13.el9.noarch
Complete!

Step 4: List the available versions of PHP by using the below command.

[root@linuxhelp ~]# dnf module list php -y
Last metadata expiration check: 0:00:37 ago on Friday 10 May 2024 03:34:59 AM.
Rocky Linux 9 - AppStream
Name                                   Stream                                     Profiles                                                     Summary
php                                    8.1                                        common [d], devel, minimal                                   PHP scripting language
php                                    8.2                                        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
php                                    remi-8.3                                   common [d], devel, minimal                                   PHP scripting language

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

Step 5: Reset PHP module and install PHP 8.2 from remi-8.2 module by usin the below command.

[root@linuxhelp ~]# dnf module reset php
[root@linuxhelp ~]# dnf module install php:remi-8.3
Last metadata expiration check: 0:00:55 ago on Friday 10 May 2024 03:34:59 AM.
Dependencies resolved.
=======================================================================================================================================================================================================
 Package                                           Architecture                            Version                                                 Repository                                     Size
=======================================================================================================================================================================================================
Installing group/module packages:
 php-cli                                           x86_64                                  8.3.6-1.el9.remi                                        remi-modular                                  5.6 M
 php-common                                        x86_64                                  8.3.6-1.el9.remi                                        remi-modular                                  1.2 M
 php-fpm                                           x86_64                                  8.3.6-1.el9.remi                                        remi-modular                                  1.9 M
 php-mbstring                                      x86_64                                  8.3.6-1.el9.remi                                        remi-modular                                  579 k
 php-xml                                           x86_64                                  8.3.6-1.el9.remi                                        remi-modular                                  220 k
Installing dependencies:
 oniguruma5php                                     x86_64                                  6.9.9-1.el9.remi                                        remi-safe                                     219 k
Installing weak dependencies:
 nginx-filesystem                                  noarch                                  1:1.20.1-14.el9_2.1                                     appstream                                     8.5 k
Installing module profiles:
 php/common
Enabling module streams:
 php                                                                                       remi-8.3

Transaction Summary
======================================================================================================================================================================================================
Total download size: 9.7 M
Installed size: 54 M
Is this ok [y/N]: y
Downloading Packages:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                  1.4 MB/s | 9.7 MB     00:06
Remi's Modular repository for Enterprise Linux 9 - x86_64                                                                                                              2.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
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Installed:
  nginx-filesystem-1:1.20.1-14.el9_2.1.noarch    oniguruma5php-6.9.9-1.el9.remi.x86_64    php-cli-8.3.6-1.el9.remi.x86_64    php-common-8.3.6-1.el9.remi.x86_64    php-fpm-8.3.6-1.el9.remi.x86_64
  php-mbstring-8.3.6-1.el9.remi.x86_64           php-xml-8.3.6-1.el9.remi.x86_64
Complete!

Step 6: Install any remaining updates by using the below command.

[root@linuxhelp ~]# dnf update

Step 7: Install PHP by using the below command

[root@linuxhelp ~]# dnf install php
Last metadata expiration check: 0:01:27 ago on Friday 10 May 2024 03:34:59 AM.
Dependencies resolved.
=======================================================================================================================================================================================================
 Package                                                             Architecture                     Version                                                Repository                           Size
=======================================================================================================================================================================================================
Installing:
 kernel                                                              x86_64                           5.14.0-427.13.1.el9_4                                  baseos                              5.8 M
Upgrading:
Installed:
  capstone-4.0.2-10.el9.x86_64  libsodium-1.0.18-8.el9.x86_64  php-8.3.6-1.el9.remi.x86_64  php-opcache-8.3.6-1.el9.remi.x86_64  php-pdo-8.3.6-1.el9.remi.x86_64  php-sodium-8.3.6-1.el9.remi.x86_64

Step 8: Verify the installed PHP version by using the below command

[root@linuxhelp ~]# php -v
PHP 8.3.6 (cli) (built: Apr 10 2024 14:21:20) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Terraform on Rocky Linux 9.3. Your feedback is much welcome.

FAQ
Q
Where can I find further assistance or documentation?
A
Refer to official Rocky Linux documentation or community forums for additional guidance and support.
Q
Is PHP 8.3 compatible with popular frameworks and applications?
A
Yes, PHP 8.3 maintains compatibility with popular web frameworks and applications.
Q
How can I verify the successful installation?
A
Run “ php -v ” to confirm PHP 8.3 installation on your system.
Q
What extensions should I install with PHP 8.3?
A
Common extensions include php-cli, php-fpm, php-mysqlnd, php-gd, php-mbstring, and others for essential functionality.
Q
How do I install PHP 8.3 on Rocky Linux 9.3?
A
Utilize the Remi repository to enable PHP 8.3 installation. Enable the PHP 8.3 module and install it alongside necessary extensions.