How to install PHP 8.0 on AlmaLinux / Rocky 8.x
Most websites and other web applications use PHP to run, it is an open source server side scripting language for generating dynamic web pages. Currently, at the time of writing this tutorial, the latest version of this language was PHP 8.0 to provide better performance for our web application. Here in this tutorial, we will learn the steps to install PHP 8.0 on AlmaLinux 8 or Rocky.
Installing PHP 8.0 on AlmaLinux or Rocky Linux
Step 1. Add the Remi repository on your Linux
By default, the version of PHP available on our AlmaLinux or Rocky install is PHP 7.2, so to get the latest version, i.e. 8.0 we need to add the third party repository to get the wide range of PHP versions.
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Step 2: Run the system update
To update the package repository so that our system can recognize the new added repository, run the update system command:
sudo dnf update
Step 3: Check the available PHP module
Let’s check which versions of PHP are available on our AlmaLinux to install. To do this, run the list of modules command using the DNF package manager.
sudo dnf module list php
You will see the PHP 8.0 version with PHP 7.x to install in Remi’s module repository for Enterprise Linux 8.
Step 4: Activate the php module: remi-8.0
As there are several versions of PHP to install, so we have to mention the version as well as the name of the repository to allow the default source to install these script packages on our system. Here is the command to execute.
sudo dnf module enable php:remi-8.0
To note: If you want to activate another module version of PHP, just change the version number in the command above.
Step 5: Command to install PHP 8.0 on AlmaLinux / Rocky from Remi Repo
Finally, run the command which will install the latest PHP on our Linux system.
sudo dnf install php -y
To install a particular extension, use the following syntax:
sudo dnf install php-extension-name
To check which extensions are installed and active for your PHP, use:
Step 5: Check the version
Once the installation is complete, let’s check which version we finally have on our system.