A LEMP software stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Nginx web server (which replaces the Apache component of a LAMP stack). The site data is stored in a MySQL database (using MariaDB), and dynamic content is processed by PHP.

In this guide, we’ll get a LEMP stack introduced on a CentOS 7 VPS. CentOS will satisfy our first necessity: a Linux working framework.

Requirements

Before you start with this guide, you ought to have a different, non-root client account set up on your server. You can figure out how to do this by finishing stages 1-4 in the underlying server setup for CentOS 7.

Note about SELinux: If you keep running into issues with Nginx not running, ensure the SELinux setting of your Nginx arrangement records is right or change the SELinux mode to lenient or disabled.

 

1. Install Nginx

With a specific end goal to show website pages to our webpage guests, we will utilize Nginx, an advanced, effective web server.
To include the CentOS 7 EPEL archive, open terminal and utilize the accompanying summon:

sudo yum install epel-release

Since we are utilizing a sudo charge, these activities get executed with root benefits. It will approach you for your general client’s secret key to check that you have the authorization to run orders with root benefits.

Now that the Nginx repository is installed on your server, install Nginx using the following yum command:

sudo yum install nginx

A while later, your web server is installed.

When it is installed, you can begin Nginx on your VPS with the following command:

sudo systemctl start nginx

You can complete a spot check immediately to confirm that everything went as arranged by going by your server’s open IP address in your internet browser (see the note under the following taking to discover off what your open IP address is whether you don’t have this data as of now):


Open in a web browser:
http://server_domain_name_or_Server_public_IP/

You will see the default CentOS 7 Nginx page, which is there for instructive and testing purposes. It should look something like this:

In the event that you see this page, at that point, your web server is currently effectively installed.

Before proceeding with, you will need to do is empower Nginx to begin on boot. Utilize the accompanying order to do as such used following command:


sudo systemctl enable nginx

Finding Your Server’s Public IP Address

On the off chance that you don’t realize what your server’s open IP address is, there are various ways you can discover it. For the most part, this is the deliver you use to interface with your server through SSH.

From the command line, you can discover this a couple of ways. To start with, you can utilize the iproute2 devices to get your address by with this command:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

 

2. Install MySQL (MariaDB)

Since we have our web server up and running, the time has come to install MariaDB, a MySQL drop-in substitution. MariaDB is a network created fork of the MySQL social database administration framework. Essentially, it will sort out and give access to databases where our site can store data information.

Once more, we can utilize yum to obtain and install our product MariaDB. This time, we’ll likewise introduce some other “partner” bundles that will help us in getting our segments to speak with each other:

sudo yum install mariadb-server mariadb

When the installation is complete, we have to begin MariaDB with the accompanying order:

sudo systemctl start mariadb

Since our MySQL database is running, we need to run a basic security content that will expel some unsafe defaults and secure access to our database framework a tad. Begin the intelligent content by running:

sudo mysql_secure_installation

The incite will approach you for your present root secret word. Since you just introduced MySQL, you doubtlessly won’t have one, so abandon it clear by squeezing enter. At that point, the incite will inquire as to whether you need to set a root secret word. Simply ahead and enter Y, and take after the guidelines:


mysql_secure_installation prompts:
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.

New password: password
Re-enter new password: password
Password updated successfully!
Reloading privilege tables..
 ... Success!

For whatever remains of the inquiries, you should basically hit the “ENTER” key through each incites to acknowledge the default esteems. This will expel some example clients and databases, cripple remote root logins, and stack these new decides with the goal that MySQL instantly regards the progressions we have made.

The exact opposite thing you will need to do is empower MariaDB to begin on boot. Utilize the accompanying charge to do as such:
sudo systemctl enable mariadb

Now, your database framework is currently set up and we can proceed onward.

3. Install PHP

PHP is the segment of our setup that will procedure code to show dynamic substance. It can run contents, associate with our MySQL databases to get data and hand the prepared substance over to our web server to show.

We can by and by using the yum framework to introduce our segments. We will incorporate the php-mysql and php-fpm bundles too:

sudo yum install php php-mysql php-fpm

 

Configure the PHP Processor

We currently have our PHP parts introduced, yet we have to roll out a slight design improvement to make our setup more secure.
Open the fundamental php arrangement record with root benefits: