Install (LAMP) stack On CentOS 7

Install Apache

To install Apache run the following:

sudo yum install httpd

Once it installs, you can start Apache on your server using:

sudo systemctl start httpd.service

To test that the web server is working use:


If you see the Apache test page, then your web server is now correctly installed. Now enable Apache to start on boot using the following:

sudo systemctl enable httpd.service

How To Find your Server’s Public IP Address

If you do not know what your server’s public IP address is you can use:

ip addr show eno1 | grep inet | awk ‘{ print $2; }’ | sed ‘s/\/.*$//’ or curl

Install MySQL (MariaDB)

MariaDB is a community-developed fork of the MySQL relational database management system. To install MariaDB use the following:

sudo yum install mariadb-server mariadb

After installation you start MariaDB with the following command:

sudo systemctl start mariadb

Run a simple security script that will remove some dangerous defaults by

sudo mysql_secure_installation

It will ask for current root password so just press enter for none and then
it will prompt you to set a root password.

Then you want MariaDB to start on boot by using the command:

sudo systemctl enable mariadb.service

Install PHP

To install PHP you need to run the following:

sudo yum install php php-mysql

Once that is installed you will need to restart the web server using:

sudo systemctl restart httpd.service

Test PHP Processing on your Web Server

If you’re not running WHM/cPanel or Plesk then run:

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

Put this code into the empty file:

<?php phpinfo(); ?>

If youre running a firewall then you may need to run these commands:

sudo firewall-cmd –permanent –zone=public –add-service=http

sudo firewall-cmd –permanent –zone=public –add-service=https

sudo firewall-cmd –reload

To test this go to:


Then if everything is ok then remove the php file using:

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

The reason this file is removed is because sometimes it can reveal information about the server we do not want unauthorised people to know.

Done LAMP is now installed on your server.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s