Deploying LAMP on Red Hat

This guide will help you deploy a LAMP stack (Linux, Apache, MySQL, PHP) on a Red Hat Enterprise Linux (RHEL) system.

Step 1: Update the System

First, ensure your system is up to date:

sudo yum update -y

Step 2: Install Apache

Install the Apache web server:

sudo yum install httpd -y

Start and enable Apache to run on boot:


sudo systemctl start httpd
sudo systemctl enable httpd
    

Allow HTTP and HTTPS traffic through the firewall:


sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
    

Step 3: Install MySQL (MariaDB)

Install MariaDB (a drop-in replacement for MySQL):

sudo yum install mariadb-server mariadb -y

Start and enable MariaDB to run on boot:


sudo systemctl start mariadb
sudo systemctl enable mariadb
    

Run the security script to secure your MariaDB installation:

sudo mysql_secure_installation

Step 4: Install PHP

Install PHP and necessary extensions:

sudo yum install php php-mysql -y

Restart Apache to load PHP:

sudo systemctl restart httpd

Step 5: Test the LAMP Stack

Create a PHP info file to test the setup:

echo "" | sudo tee /var/www/html/info.php

Open a web browser and navigate to http://your_server_ip/info.php to see the PHP information page.

Conclusion

You have successfully deployed a LAMP stack on your Red Hat Enterprise Linux system.

Other Recent Posts