How To Install Linux, Apache, MySQL, PHP (LAMP) stack On RHEL 8

Installing a LAMP (Linux, Apache, MySQL, PHP) stack on RHEL 8 can be done by following these steps:

  1. Install Apache web server:
sudo dnf install httpd
  1. Start the Apache service and enable it to start automatically at boot time:
sudo systemctl start httpd
sudo systemctl enable httpd
  1. Install MySQL server and client:
sudo dnf install mariadb-server mariadb
  1. Start the MySQL service and enable it to start automatically at boot time:
sudo systemctl start mariadb
sudo systemctl enable mariadb
  1. Secure your MySQL installation by running the following command:
sudo mysql_secure_installation
  1. Install PHP and the PHP module for Apache:
sudo dnf install php php-mysqlnd
  1. Enable the PHP module for Apache by editing the Apache configuration file:
sudo nano /etc/httpd/conf.d/php.conf

and add the following line:

LoadModule php7_module modules/libphp7.so
  1. Restart the Apache service to apply the changes:
sudo systemctl restart httpd
  1. Verify that PHP is working by creating a file called info.php in the Apache document root directory:
sudo nano /var/www/html/info.php

with the following contents:

<?php
phpinfo();
?>
  1. Access the file in a web browser:
http://your_server_ip/info.php

The above steps will install a LAMP stack on your RHEL 8 system. You can now use this stack to host dynamic websites and web applications that use PHP and MySQL.

Leave a Comment