Looking for CentOS help? Visit our CentOS 7 help and tutorials page.

LAMP, as acronym for Linux, Apache, MySQL and PHP represents an Open Source web development platform that uses Linux operating system, Apache web server, MySQL database, and PHP as the scripting language. Together, these components have what it takes to build a robust web application platform. CentOS (Community Enterprise Operating System) is a Linux-based community supported enterprise OS. Its latest version, CentOS 7, was launched in July, 2014.

In this tutorial, we will look into the steps required to install LAMP in Centos 7.




Before we begin with the installation, let us check our hostname, using the command

#hostname –f

which should return our FQDN of the server.

The system can be checked for updates and updated using the commands

#yum check-update

#sudo yum update


Installing Apache


To install Apache, we run the command

#yum install httpd

Next is to enable the Apache service at startup.

#systemctl enable httpd.service

#systemctl restart httpd.service

The Apache server can be tested now!

To prevent the firewall of your network to block the service, the Apache port number (80) can be excluded from the firewall.

#firewall –cmd –permanent –add-service httpd

#systemctl restart firewall.service


Installing MySQL


MySQL has been replaced by MariaDB in CentOS. To install MariaDB, we would perform the following steps:

To install MariaDB, we run the following command

#sudo yum install mariadb-server

To enable MariaDB at startup, run the following command

#sudo systemctl enable mariadb.service

#sudo systemctl start mariadb.service

To password protect MariaDB installation, we can use the following


It would prompt for the current password. We would leave that blank and the system would prompt for the new password. We would set a new password, confirm it.

Installing PHP


To install PHP, we run the following command

#yum install php php-mysql

This command would install the MySQL support, in addition to PHP.

Next we create a log directory for PHP and assign ownership

#sudo mkdir /var/log/phplogdir

#sudo chown /var/log/phplogdir

We will restart the Apache service now

#systemctl restart httpd.service

To test, we can create a demo PHP page and check in the browser.


To check the installed versions of the services, we can use the following commands

#php –v

#httpd –v

#mysql –v

Now that we have configured LAMP on CentOS 7, we have a platform to configure almost all powerful websites available. Happy computing!