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

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

To install the Linux, Apache, MariaDB, PHP (LAMP) stack on a CentOS or Red Hat Enterprise Linux (RHEL) 7 system, you can follow these steps:

  1. Update your system's package repositories by running the following command:
refer‮ot ‬:lautturi.com
sudo yum update

This will ensure that you have the latest packages and security updates installed on your system.

  1. Install the Apache HTTP server by running the following command:
sudo yum install httpd

This will install Apache and all of the necessary dependencies.

  1. Start the Apache HTTP server by running the following command:
sudo systemctl start httpd
  1. Enable the Apache HTTP server to start automatically when the system boots by running the following command:
sudo systemctl enable httpd
  1. Install the MariaDB database server by running the following command:
sudo yum install mariadb-server mariadb

This will install MariaDB and all of the necessary dependencies.

  1. Start the MariaDB database server by running the following command:
sudo systemctl start mariadb
  1. Enable the MariaDB database server to start automatically when the system boots by running the following command:
sudo systemctl enable mariadb
  1. Secure the MariaDB database server by running the following command:
sudo mysql_secure_installation

This will prompt you to set a root password for the MariaDB database server and to remove anonymous users and test databases.

  1. Install the PHP programming language by running the following command:
sudo yum install php php-mysql

This will install PHP and the PHP MySQL extension, which allows PHP to communicate with the MariaDB database server.

  1. Restart the Apache HTTP server to apply the changes by running the following command:
sudo systemctl restart httpd
  1. Test the LAMP stack by creating a PHP file in the Apache document root directory (/var/www/html) and accessing it through a web browser. You can do this by running the following commands:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
firefox http://localhost/info.php
Created Time:2017-10-28 14:02:22  Author:lautturi