CentOS and RHEL 7: Install Linux, Apache, MariaDB, PHP (LAMP) Stack

Here’s a step-by-step guide to install the LAMP (Linux, Apache, MariaDB, PHP) stack on CentOS and RHEL 7:

  1. Install Apache:
sudo yum install httpd
  1. Start and enable the Apache service:
sudo systemctl start httpd
sudo systemctl enable httpd
  1. Install MariaDB:
sudo yum install mariadb-server mariadb
  1. Start and enable the MariaDB service:
sudo systemctl start mariadb
sudo systemctl enable mariadb
  1. Secure MariaDB:
sudo mysql_secure_installation
  1. Install PHP:
sudo yum install php php-mysql
  1. Restart Apache to enable PHP:
sudo systemctl restart httpd
  1. Test PHP by creating a file called ‘info.php’ in the document root directory ‘/var/www/html’ with the following content:
<?php
phpinfo();
?>
  1. Open a web browser and access ‘http://localhost/info.php‘ to view the PHP information page.

With these steps, you have installed and set up a basic LAMP stack on your CentOS or RHEL 7 system. You can now use Apache and PHP to serve web content, and MariaDB to store and manage data.

(https://www.adarsus.com)

Leave a Comment