lamp

How to Install LAMP with Latest Version of PHP on RHEL: A Step-by-Step Guide 2023

Lamp

If you’re looking to set up a web server on your RHEL (Red Hat Enterprise Linux) system, you’ll need to install a stack of software called LAMP, which stands for Linux, Apache, MySQL, and PHP. This blog will guide you through the process of installing LAMP with the latest version of PHP on RHEL.

Step 1: Update the system

Before you start installing anything, make sure your system is up-to-date. To do this, run the following command:

sudo yum update

This will update all the packages on your system to the latest versions.

Step 2: Install Apache

Apache is a widely used web server that will allow your system to serve web pages. To install Apache, run the following command:

sudo yum install httpd

Once the installation is complete, start the Apache service and enable it to start automatically at boot time:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Install MySQL

MySQL is a popular open-source database management system. To install MySQL, run the following command:

sudo yum install mysql-server

Once the installation is complete, start the MySQL service and enable it to start automatically at boot time:

sudo systemctl start mysqld.service
sudo systemctl enable mysqld.service

During the installation process, you will be prompted to set a root password for MySQL. Make sure you remember this password as it will be required later.

Step 4: Install the latest version of PHP

The default version of PHP that comes with RHEL may not be the latest version available. To install the latest version of PHP, you’ll need to enable the Remi repository, which contains the latest versions of PHP.

First, install the Remi repository:

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Once the repository is installed, enable the latest version of PHP:

sudo yum module reset php
sudo yum module enable php:remi-8.1

Finally, install PHP and its required extensions:

sudo yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath

Step 5: Restart the Apache service

To load the new version of PHP, restart the Apache service:

sudo systemctl restart httpd.service

Step 6: Verify the installation

To verify that LAMP with the latest version of PHP has been installed correctly, create a PHP test script by running the following command:

sudo nano /var/www/html/info.php

This will open a new file in the nano text editor. Enter the following code into the file:

<?php
phpinfo();
?>

Save the file and close the text editor.

Now open a web browser and enter the IP address of your RHEL system followed by “/info.php” in the address bar. For example, if your RHEL system’s IP address is 192.168.1.100, enter “http://192.168.1.100/info.php” in the address bar. You should see a page containing information about your PHP installation, including the version number.

Step 7: Secure the installation

By default, the LAMP installation is not very secure. To improve the security of your installation, run the following command:

sudo mysql_secure_installation

This command will prompt you to configure the MySQL root password, remove anonymous users, disallow remote root login, and remove the test database. Follow the prompts to secure your MySQL installation.

Conclusion

In this blog, we have shown you how to install LAMP on RHEL. With this installation, you now have a powerful web server that can serve dynamic web pages and store data in a database. Remember to keep your system up-to-date and secure to prevent any potential security threats.

Tags: No tags

Add a Comment

Your email address will not be published. Required fields are marked *