How to Install LAMP on CentOS 7


LAMP Stack is a bunch of open supply packages that work collectively to allow a server to host dynamic web sites or net purposes. LAMP represents Linux (working system), Apache (net server), MySQL (MariaDB database), PHP (scripting language). On this information, we are going to learn the way to set up LAMP on CentOS 7.



Replace the software program packages of your CentOS Server to the newest model. To do this run the next command:

sudo yum -y replace

This tutorials requires you to have root entry of your server. In case you are working on Home windows, you’ll require an SSH shopper like PuTTY.

How to Install LAMP on CentOS

Now that Linux (CentOS) is already put in and software program packages are up to date to the newest model, we will probably be putting in Nginx, MySQL and PHP.

Step #1: Install Apache on CentOS 7

Apache net server is the most well-liked net server on the planet. Most significantly, it’s a nice alternative for internet hosting an internet site.

We are able to simply set up Apache net server utilizing the yum package deal manger of CentOS.

sudo yum set up httpd

Since we’re utilizing a sudo command, the set up command will get executed with root privileges and you’ll be requested to enter the common consumer’s password.

As soon as it installs, you can begin the Apache net server on your CentOS VPS by working:

sudo systemctl begin httpd.service

Apache net server ought to be up and working on your server. You’ll be able to verify the standing of your Nginx net server by typing:

sudo systemctl standing httpd

Now, we might need our Apache to begin robotically on server boot. To allow that, run:


sudo systemctl allow httpd.service

Now enter the IP deal with of your server within the browser and press enter. You need to see a web page one thing like this:

If you happen to have no idea the IP deal with of your server, you should utilize a software known as iproute2.

ip addr present eth0 | grep inet | awk '{ print $2; }' | sed 's//.*$//'

Alternatively, you’ll be able to sort:


Step #2: Installing MySQL (MariaDB)

Now that we now have put in Apache net server up and working, it’s time to set up MySQL (MariaDB).

MariaDB is a community-developed fork of MySQL database. It’s a commercially supported and meant to stay free and open-source software program beneath GNU Normal Public Licence.


To put in MariaDB server together with MySQL/MariaDB-PHP, run:

sudo yum set up mariadb-server php-mysql

Now allow and begin the MariaDB service by typing:

sudo systemctl begin mariadb
sudo systemctl allow mariadb

On this step, we want to safe the MariaDB set up by working:

sudo mysql_secure_installation

When you hit enter, a immediate will ask you to enter the present root password, which you do not need because you simply put in the MariaDB. So you’ll be able to go away the password subject clean and press enter.

Now the immediate will present you a password affirmation possibility. You want to sort Y and press enter and observe the directions to set the password.

Now immediate will return a collection of safety questions. Reply Y for the next prompts:

Take away nameless customers? [Y/n]
Disallow root login remotely? [Y/n]
Take away take a look at database and entry to it? [Y/n]
Reload privilege tables now? [Y/n]

We additionally want to allow the MariaDB in order that it begins robotically each time a server is rebooted. To do this, run:

sudo systemctl allow mariadb

Step #3: Install PHP

To run our web site or net software and show dynamic content material, set up the PHP FastCGI processing supervisor.

We’re alsogoing to set up php-mysql and php-fpm packages by leveraging the CentOS package deal supervisor yum:

sudo yum set up php php-mysql php-fpm

Make sure that PHP is up and working:

sudo systemctl begin php-fpm

Additionally, allow php-fpm to begin the robotically on server reboot:

sudo systemctl allow php-fpm

Step #4: Take a look at PHP Processing

So as to take a look at our LAMP Stack configuration, create an index.php file inside the foundation listing of your web site

sudo nano /var/www/

Paste the next one line code:

Save the index.php file by urgent CTRL + X.

Now restart the PHP-FPM and Apache:

sudo systemctl restart php-fpm
sudo systemctl restart httpd.service

Now go to

Substitute together with your area title.

It should open a web page containing PHP info which is able to look one thing like this:

Default php-fpm

It additionally confirms the profitable set up of LAMP Stack.

[icon name=”fa-hand-o-right”] You might also like: How to Install LEMP on CentOS 7: 5 Simple Steps


On this information, we coated how to set up LAMP on CentOS 7. I hope you can see this tutorial helpful.

When you have any questions or suggestions, be at liberty to remark beneath.

Leave a comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More