
PHP (Hypertext Preprocessor) is an open-source server-side scripting language used extensively in web development. To leverage its latest features and improvements, you can install PHP 8 on Rocky Linux 9. PHP is also a general-purpose language for creating APIs, dynamic websites, and server-side applications.
This article explains how to install and configure PHP 8 on Rocky Linux 9. You will add the required repositories, install the latest stable PHP 8 version, and set up PHP-FPM to process PHP scripts. After installation, you will test the setup to ensure PHP 8 is working.
Before you begin, you need to:
Rocky Linux 9 includes PHP 8.1 and 8.2 in its default repositories. To install a newer, stable version, you must enable the Remi repository, which provides the latest PHP packages. The EPEL (Extra Packages for Enterprise Linux) repository is required as a dependency. Follow the steps below to install the EPEL and Remi repositories.
Update the server's package information index.
Install the EPEL repository.
Install the Remi repository.
Verify the installation of EPEL and Remi repositories.
Output:
Reset the PHP module to clear existing configurations.
With the required repositories enabled, follow the steps below to install PHP 8.4, the latest stable version, and the necessary extensions.
Enable the Remi repository for PHP 8.4
Install PHP 8.4
Install Necessary PHP Extensions.
Verify the PHP Installation.
Output:
PHP-FPM (FastCGI Process Manager) is a daemon that handles PHP scripts, improves performance, and increases scalability. It runs PHP applications with web servers like Nginx and Apache. Follow the steps below to install and configure PHP-FPM.
Install PHP-FPM.
Start the PHP-FPM service.
Set PHP-FPM to start at system boot.
Check PHP-FPM Status.
Output:
Follow the steps below to verify and test your PHP 8 installation using the Apache web server. You will create a PHP information file to check the installation and ensure your server can process PHP scripts.
Install the Apache web server.
Start the Apache service.
Enable Apache to start on Boot.
Check the status of Apache.
Output:
Add a rule to your firewall to allow HTTP traffic on port 80.
Reload the firewall to make the changes effective.
Create a test file in the Apache web root directory.
Add the following PHP code to this file. It will display detailed information about your PHP installation.
Save and close the file.
Restart Apache.
Access your server's IP address using a web browser, such as Chrome, and load the /info.php URL path to view the PHP information page and confirm the installation of PHP 8.4.5.
Replace 192.0.2.11 with the actual IP address of your Rocky Linux 9 instance in the above link.
You have installed PHP 8.4 on your Rocky Linux 9 instance and configured it to process PHP scripts using PHP-FPM. You also installed and set up an Apache web server to serve PHP applications and tested your installation by creating a PHP information file. Your server is now ready to run the latest stable version of PHP applications. To enhance security and performance, refer to the official PHP documentation.
0 Comments
Be the first to comment and share your perspective with the community.