How to Install LAMP stack on CentOS 7

Install LAMP stack on CentOS 7

In this article, we will have explained the necessary steps to install and configure LAMP Stack on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

LAMP is short for Linux, Apache, MySQL or PHP which is an open source web development platform. It uses Linux as it’s operating system while Apache and MySQL are used as a web & database servers, the PHP is also used as an object oriented scripting language to work as a complete web stack, which is used to prepare servers for hosting web content.

Install LAMP stack on CentOS 7

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Step 2. Installing Apache.

Run the following command with root user to install apache http server with yum repositories:

Once the installation is completed, start and enable the Apache service by typing:

Step 3. Installing MariaDB.

To install MariaDB type following command:

Once MariaDB server is installed, start and enable the service with:

Step 4. Installing PHP.

Add remi repository in CentOS so we can install latest PHP 7.2, typing following command:

Now enable PHP72 package using below command:

Then, that we have Remi repository enabled, we can install PHP FPM and several most common PHP modules with:

Once the PHP packages are installed restart the Apache service with:

Step 5. Testing PHP

Now you should create info.php file to test php to do so type following:

Then open the following link in your web browser and we will be able to see all the information about PHP and its other configurations: http://your-domain/phpinfo.php (replacing your IP address with the one above).

That’s all you need to do to Install LAMP Stack on CentOS 7. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.