AlmaLinux 9 is a popular operating system choice for many businesses and individuals. While it comes with PHP 8.0 by default, you may find the need to install newer versions, such as PHP 8.1, for your projects. In this article, we will guide you through the process of installing PHP 7.4 and 8.1 on AlmaLinux 9 using the Remi repository.
Prerequisites
Before we begin, make sure you have a system with AlmaLinux 9 installed and root access to the system. It’s also a good practice to ensure that your system is up-to-date by running the following command:
dnf update
Installing the EPEL and Remi Repository
To install PHP 8.1, we need to add and enable the Remi RPM repositories. Before that, we also need to install the EPEL repository. Let’s start by installing the EPEL repository with the following command:
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Next, we can install the Remi repository by running the following command:
dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
This will add the Remi repository to your system, which contains the PHP 8.1 packages that we need.
Listing Available PHP Versions
Once the Remi repository is installed, you can list the available PHP module streams by running the following command:
dnf module list php
This command will display the available PHP versions, including PHP 7.4, PHP 8.0, and PHP 8.1.
Installing PHP 7.4
To install PHP 7.4, we can use the remi repository. Run the following command to install PHP 7.4:
dnf module install php:remi-7.4
This command will install the necessary PHP packages and dependencies for PHP 7.4.
Verifying the Installed PHP Version
After the installation is complete, you can verify the installed PHP version by running the following command:
php -v
The command will display the PHP version installed on your system. In this case, it should show PHP 7.4.
Installing PHP 8.1
Now, let’s proceed with installing PHP 8.1. Run the following command to install PHP 8.1:
dnf module install php:remi-8.1
This command will install the PHP 8.1 packages and dependencies from the Remi repository.
Verifying the Installed PHP Version
After the installation is complete, you can verify the installed PHP version by running the following command:
php -v
The command will display the PHP version installed on your system. This time, it should show PHP 8.1.
Updating the System and Installing Packages
To keep your system up-to-date and install any necessary packages, you can run the following command:
dnf update
This command will update your system and install any available updates.
Conclusion
In this article, we have walked through the process of installing PHP 7.4 and 8.1 on AlmaLinux 9 using the Remi repository. By following these steps, you can easily upgrade your PHP version and take advantage of the new features and improvements offered by PHP 8.1. Remember to keep your system up-to-date and install any necessary updates to ensure the security and stability of your applications.
If you’re looking for reliable and scalable cloud hosting solutions, Shape.host can provide you with Cloud VPS services. With Shape.host, you can enjoy the benefits of high-performance cloud infrastructure, robust security measures, and excellent customer support. Upgrade your hosting experience with Shape.host today!