Rocky Linux 8 is a popular Linux distribution known for its stability and reliability. If you’re looking to install PHP 7.3 on your Rocky Linux 8 machine, you’re in the right place. In this article, we’ll guide you through the step-by-step process of installing PHP 7.3 and its associated modules. Whether you’re a developer or a system administrator, this guide will help you get PHP up and running smoothly on your Rocky Linux 8 system.
Prerequisites
Before we begin, make sure you have full root access to your Rocky Linux 8 machine. This will allow you to install packages and make system-wide changes. Additionally, ensure that you have a stable internet connection to download the necessary packages from the repositories.
Adding the Remi Repository
The first step in installing PHP 7.3 is to add the Remi repository to your Rocky Linux 8 system. The Remi repository is a third-party repository that offers multiple versions of PHP. To add the Remi repository, open your terminal and run the following command:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Once the Epel repository is installed, you can proceed to install the Remi repository by running the following command:
yum install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Listing Available PHP Module Streams
After successfully adding the Remi repository, you can now list the available PHP module streams. These streams represent different versions of PHP that you can install on your system. To check the available PHP module streams, use the following command:
yum module list php
The command will display a list of available PHP module streams from both the Rocky Linux 8 – AppStream and Remi repositories. Here’s an example of the output you can expect:
Repository |
Name |
Stream |
Profiles |
Summary |
---|---|---|---|---|
Rocky Linux 8 – AppStream |
php |
7.2 |
common, devel, minimal |
PHP scripting language |
Rocky Linux 8 – AppStream |
php |
7.3 |
common, devel, minimal |
PHP scripting language |
Rocky Linux 8 – AppStream |
php |
7.4 |
common, devel, minimal |
PHP scripting language |
Remi’s Modular repository for Enterprise Linux 8 |
php |
remi-7.2 |
common, devel, minimal |
PHP scripting language |
Remi’s Modular repository for Enterprise Linux 8 |
php |
remi-7.3 |
common, devel, minimal |
PHP scripting language |
Remi’s Modular repository for Enterprise Linux 8 |
php |
remi-7.4 |
common, devel, minimal |
PHP scripting language |
Remi’s Modular repository for Enterprise Linux 8 |
php |
remi-8.0 |
common |
PHP scripting language |
In the above example, you can see that PHP 7.3 is available in both the Rocky Linux 8 – AppStream and Remi repositories. You can choose to enable either one of them to install PHP 7.3 on your system.
Enabling PHP 7.3 Module
To install PHP 7.3, you need to enable the PHP 7.3 module. Before enabling the module, it’s recommended to reset the PHP module using the following command:
yum module reset php
Once the module is reset, you can enable the PHP 7.3 module by running the command:
yum module enable php:remi-7.3 -y
The command will enable the PHP 7.3 module and resolve any dependencies required for the installation. Here’s an example of the output you can expect:
Dependencies resolved. ============================================================================================= Package Architecture Version Repository Size ============================================================================================= Enabling module streams: php remi-7.3 common[d], devel, minimal
The PHP 7.3 module is now enabled, and you can proceed with the installation.
Installing PHP 7.3
With the PHP 7.3 module enabled, you can now install PHP 7.3 on your Rocky Linux 8 system. To install PHP 7.3, use the following command:
yum install -y php php-cli php-common
The command will install PHP 7.3 along with the necessary PHP command-line interface (CLI) and common modules. Once the installation is complete, you can verify the PHP version by running the command:
php -v
The output should display the PHP version, similar to the following:
PHP 7.3 (cli) (built: May 4 2021 17:26:18) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies
Congratulations! You have successfully installed PHP 7.3 on your Rocky Linux 8 system.
Installing PHP-FPM
If you’re setting up a LEMP stack on your Rocky Linux 8 system, you might want to install PHP-FPM (FastCGI Process Manager) along with PHP. PHP-FPM is a fast and efficient way to handle PHP requests and is commonly used in conjunction with Nginx. To install PHP-FPM 7.3, use the following command:
yum install -y php-fpm
Once the installation is complete, you can check the PHP-FPM version by running the command:
php-fpm -v
The output should display the PHP-FPM version, similar to the following:
PHP 7.3 (fpm-fcgi) (built: May 4 2021 17:26:18)
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies
Now you have PHP-FPM installed on your Rocky Linux 8 system, ready to be used with your web server.
Conclusion
In this article, we’ve walked you through the process of installing PHP 7.3 on Rocky Linux 8. We started by adding the Remi repository, listing the available PHP module streams, and enabling the PHP 7.3 module. Then, we installed PHP 7.3 and verified the installation by checking the PHP version. Additionally, we covered the installation of PHP-FPM for those setting up a LEMP stack. With PHP and PHP-FPM installed, you’re now ready to develop and deploy PHP applications on your Rocky Linux 8 system.
If you’re looking for reliable and scalable cloud hosting solutions for your PHP applications, Shape.host is here to help. With our Linux SSD VPS, you can enjoy high-performance hosting with dedicated resources and full root access. Get started with Shape.host today and experience the power of secure and efficient PHP hosting.