How to install LEMP server on Debian 9?

0
345
LEMP
LEMP

Many web developers prefer Nginx to Apache. Actually, Nginx has a better performance but a slightly more delicate configuration than Apache. So today I’ll show you how to install the LEMP server on Debian 9.

You probably know that LAMP (Linux, Apache, MySQL /MariaDB, and PHP) is a basic stack for setting up a functional web server. With this server, you can start developing applications or simply run them.

The problem is that many prefer Nginx to Apache. This may be because of their wide performance gap, or simply a matter of necessity. The detail is that simple, we are going to install a LAMP server but with Nginx. That’s why it’s LEMP.

So, let’s install LEMP on Debian.

Install Nginx

The first step to install LEMP is to install the first of its components (apart from Linux, obviously) and that is Nginx. You can do this from the official Debian repositories. However, before to install it, I recommend upgrading the system.

1.- Upgrading the system
1.- Upgrading the system

Next, install Nginx.

2.- Install Nginx
2.- Install Nginx

Then, enable and start the service.

3.- Enabling and starting the Nginx service
3.- Enabling and starting the Nginx service

In case you have ufw enabled, you need to run this command.

Now, it is done.

Install MariaDB

The second step is to install and configure MariaDB. MariaDB is a popular database manager among developers. It is also available in the official Debian repositories.

You just need to type:

4.- Installing MariaDB
4.- Installing MariaDB

Then, enable and start the MariaDB service.

systemctl start mariadb systemctl enable mariadb
5.- Enabling MariaDB service

Next, set a root password using the mysql_secure_installation script.

6.- Using the mysql_secure_installtioin script
6.- Using the mysql_secure_installtioin script

In this script, several questions will be asked. You can answer as you want since the configuration depends on each user, in my case, I have answered Y, N, Y, Y.

Install and configure PHP

Now, you need to install PHP to run the web applications. It is simple to do it.

7.- Installing php
7.- Installing PHP

Next, you need to tell Nginx to use PHP. To do it, you need to edit the Nginx default site configuration file.

Leave it as I show it in the image.

8.- Enabling PHP support on Nginx
8.- Enabling PHP support on Nginx

Then, create a .PHP file to verify that everything is in order.

9.- Creating a sample PHP file
9.- Creating a sample PHP file

Finally, open your web browser and go to HTTP://IP_SERVER/index.php

10.- PHP running
10.- PHP running

Now, you know how to install LEMP on Debian 9.

Conclusion

As you can see, it is not so complicated to install LEMP on your server with Debian 9. On the contrary, it is something simple that won’t take you long.

Please share this file with your friends.

Spread the love
  • 5
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here