This tutorial intends to teach you to Upgrade the PHP Version to the latest on AlmaLinux 8 and Rocky Linux 8. The default version of PHP that is available in AlmaLinux 8 and Rocky Linux 8 isn’t up to date. So we decided to provide this guide that you can use to update your PHP version to the latest version.
Steps To Upgrade PHP Version To the Latest on AlmaLinux 8 and Rocky Linux 8
Here we assumed that you have PHP installed on your server, but it is not in the latest version. To update it, you must have access to your server as a non-root user with sudo privileges. For this purpose, you can visit the following initial guides:
In both servers, you can use the following instructions to update your PHP version to the latest.
Step 1 – Check the Current PHP Version on AlmaLinux 8 and Rocky Linux 8
At this point, to show you the guide steps, we use AlmaLinux 8. Check the current PHP version installed on the server with the following command:
Output PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
As you can see, PHP 7.2 that is installed is out of date and you should update your PHP version.
Step 2 – Install Remi Repository on AlmaLinux 8 and Rocky Linux 8
To upgrade your PHP version, you must install the Remi repository on your server.
Remi’s RPM repository is a free and stable YUM repository mainly for the PHP stack.
To do this, run the command below:
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
At this point, use the following command to install the yum-utils package:
sudo dnf install yum-utils -y
Step 3 – Update the PHP Version To The Latest
Next, you need to enable the Remi for the latest stable version of PHP. At the current time, the latest stable version of PHP is PHP 8.2. First, reset the default PHP module with the command below:
sudo dnf module reset php -y
Then, enable the Remi repo for PHP 8.2 with the command below:
sudo dnf module install php:remi-8.2 -y
Then, update your local package index:
sudo dnf update -y
Check your PHP version again:
Output PHP 8.2.10 (cli) (built: Aug 29 2023 15:31:38) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.2.10, Copyright (c) Zend Technologies with Zend OPcache v8.2.10, Copyright (c), by Zend Technologies
As you can see, PHP has been upgraded to the latest version.
At this point, you have learned to Upgrade the PHP version to the latest on AlmaLinux 8 and Rocky Linux 8. Because the default version of PHP in AlmaLinux 8 and Rocky Linux 8 is PHP 7.2 and it is out of date. So it is recommended to upgrade it.
Hope you enjoy it. Need any help or suggestions? Please comment for us.
For more guides and articles, you can visit the Orcacore website.