CentOS 7: Install LAMP Stack

This blog receives a commission from affiliate partners through the affiliate links that we share with you in our posts. Although we receive a commission for using and linking their products, all our opinions and suggestions are unbiased.

What is LAMP Stack?

LAMP stack is a group of open-source software that is usually installed together to enable a server to host websites and web applications. The acronym represents L for the Linux Operating System, A for Apache Web Server, M for MySQL, and P for PHP. In this tutorial, we will cover how to install the LAMP stack on your CentOS Linux Server.

If it is working you will see a default test page which indicates that your Apache Web server installation was successful.

The last step you should take to complete your Apache installation is to enable Apache Web server to start on boot:

sudo systemctl enable httpd.service

Install MySQL (MariaDB)

Once our web server is up and running we will go to step number two and install MySQL (MariaDB). MariaDB is a community-developed fork of the MySQL relational database management system.

We will use the yum package manager like in our first step to install MySQL(MariaDB).

sudo yum install mariadb-server mariadb

Once the MariaDB installation has completed then we will start it.

sudo systemctl start mariadb

Once the MySQL database is running, we will then run a simple security script that will remove defaults and lock down access to our database system. Start the script by running the following:

sudo mysql_secure_installation

A prompt will ask for your current root password. If you just installed MySQL then you can leave it blank and press enter. The prompt will then ask if you want to set a root password. You can go ahead and enter Y and follow the instructions:

If this was successful then your PHP setup and configuration are working. We will then remove the info.php file as it could give unauthorized users information about your server:

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

You can recreate the file later if you should require the information again. After all the tests and configurations you have completed the LAMP stack installation on your CentOS server. It is now ready to host websites and web applications.

Chad Crouch

Chad is an experienced Systems Administrator with exposure to various technologies and enterprise ICT environments. He has a huge passion for Technologies, specifically Linux, Open Source Software, Cloud Computing, DevOps, Software & Web Development, electronics, and IoT technologies.
If you enjoy our articles please support us and make a small contribution: Buy Us A Coffee