How to install PHP 8.2 on AlmaLinux 8/9


PHP is a popular opensource server-side scripting language that is used for the development of dynamic websites. At the moment, PHP 8.2 is the most recent version of PHP. In this article, you will learn how to install PHP 8.2 on AlmaLinux 8/9.

Step 1: Upgrade the System Packages

To get off the ground, login to your AlmaLinux instance and upgrade the system by running the following command:

$ sudo dnf update

Step 2: Install Remi Repository on AlmaLinux 9

PHP 8.2 is not yet officially included in the AppStream repository for AlmaLinux 9. As such, we are going to install it from Remi repository which is a third-party repository that provides the latest versions of PHP. But first, we need to install EPEL repository.

To instal EPEL 9, run the following commands.

$ sudo dnf config-manager --set-enabled crb
$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
install EPEL AlmaLinux 9

Once installed, you can verify that EPEL has been installed as follows.

$ rpm -qi | grep epel-release
confirm EPEL repository is added AlmaLinux 9

Once EPE is installed, install Remi repository by running the following commands:

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

Next, install the yum-utils package.

$ sudo dnf -y install yum-utils

Step 3: Install PHP 8.2 on AlmaLinux 9

The next step is to install PHP 8.2 from Remi repository. However, before you do so, reset the PHP module on your system.

$ sudo dnf module reset php

Next, enable the php:remi-8.2 module as shown

$ sudo dnf module install php:remi-8.2
enable PHP 8.2 Remi module on AlmaLinux

Then update the repositories.

$ sudo dnf update

Then install PHP 8.2 from Remi repository as follows.

$ sudo dnf install php -y

Run the following command to confirm that PHP has been installed.

$ php -v

In addition, you can confirm from a web browser by , first , installing Apache HTTP web server and then creating a phpinfo page in the web root directory.

To install Apache web server, run the command:

$ sudo dnf install httpd -y

Once installed, start and enable the web server.

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

Next, create a phpinfo page using the following steps.

$ sudo vim /var/www/html/info.php

Add the following lines:

<?php
phpinfo();
?>

Save the changes and exit. Then browse your server’s IP address

http://server-ip/info.php

You should see the following web page, confirming that PHP 8.2 has been installed.

PHP 8.2 installed on AlmaLinux 9

Conclusion

In this short guide, we have walked you through the installation of PHP 8.2 on AlmaLinux 9.0. Your feedback on the guide will be appreaciated.

Print Friendly, PDF & Email
Categories