How to install LAMP on CentOS 7

LAMP is a software system for building web server environment written in PHP. This article will help you learn as well as instructions on how to install LAMP on a CentOS machine.

1. Overview

LAMP is a software system for building a web server environment capable of storing and distributing dynamic web pages written in PHP.


LAMP includes:

  • Linux: is the operating system, also the software used to coordinate and manage system resources.

  • Apache: is a web server software that can make requests to the server via HTTP

  • Mysql / Mariadb: is the database management system that helps store and retrieve data. Both of these two database management systems are quite similar (can learn more here).

  • PHP: The programming language for the server operation scenario.

2. Proceed with the installation

2.1. Install linux

For the operating system installation, you can show it on many different distributions of linux such as Debian, Redhat, Ubuntu ... In this article, I use CentOS 7.

2.2. Install Apache

To install, on the terminal window type the command:

sudo yum -y install httpd

Finished installation, proceed to restart the service:

systemctl start httpd
systemctl enable httpd

You can check the service's performance status by typing:

systemctl status httpd


You can also check the status in your browser by typing in the following address bar:

<địa chỉ ip server>


If you use the operating system on a virtual machine, you can turn off the firewall so that you can access it in the real machine's browser:

systemctl stop firewalld

Then, typing the virtual machine's ip address on the url bar will produce the same result.

2.3. Install database management system

Actually with LAMP, you can use either mysql or mariadb either, in this tutorial I will guide you with mariadb.

On the terminal window, install mariadb:

sudo yum -y install mariadb mariadb-server

Proceed to start the mariadb service:

systemctl start mariadb

Reset the password for the root of the database:

sudo mysql_secure_installation


In this step we will set up some configuration as follows:

Enter currret password for root (enter for none):

This step requires you to enter a recent password for root. If you are installing for the first time, press Enter to skip.

Set root password? (Y/n)

If you install it for the first time, the system will ask if you want to set a password for root access. You type Y -> Enter, then enter the password and verify the password.


For newly installed mariadb machines for the first time, the system requires some additional settings as follows:

  • Delete other users.

  • Do not allow root to login remotely.

  • Delete the databases test.

  • Relaunch the Privilege table.

You just need to type Y for those requirements.

Once setup is complete, activate mariadb to boot with the system:

systemctl enable mariadb

2.3. Install php

The version available in repos of CentOS is 5.4. This version is quite old and will cause you some problems when installing wordpress. So you need to install 7x to fix it. You need to add the repository to Remi CentOS:

rpm -Uvh

Install yum-utils because we need the yum-config-manager utility to install:

yum -y install yum-utils

Install php. Here we need to note about the installed version as follows:

  • Version 7.0:

yum-config-manager --enable remi-php70
yum -y install php php-opcache php-mysql

  • Version 7.1:

yum-config-manager --enable remi-php71
yum -y install php php-opcache php-mysql

  • Version 7.2:

yum-config-manager --enable remi-php72
yum -y install php php-opcache php-mysql

  • Version 7.3:

yum-config-manager --enable remi-php73
yum -y install php php-opcache php-mysql

In this article, I installed version 7.2

After installation is complete, restart apache:

systemctl restart httpd

Proceed to check the results. We add the following file:

echo "<?php phpinfo();?>" > /var/www/html/info.php

Then restart apache:

systemctl restart httpd

In your browser, type in the following address bar:

<địa chỉ ip>/info.php

When this screen appears, you're done!



seo marketing wordpress seo seo hosting seo and marketing word press seo wordpress and seo wordpress marketing hosting seo seo press pro market seo seo & marketing seo e marketing e marketing seo seo pro wordpress marketing & seo seo di wordpress wordpress seo host hosting and seo wordpress hosting seo wordpress seo wordpress wordpress for marketing seo press wordpress marketing for seo