How To Install LEMP Stack on Debian 10


LEMP Stack consists of Linux, Nginx, MariaDB, and PHP. This stack is most widely used for hosting high traffic websites.

Here, we will see how to install LEMP Stack on Debian 10 with PHP support (via PHP-FPM) and MariaDB support.


To be able to install LEMP stack on Debian 10, you need to have sudo privileges on the system.

Install LEMP Stack

Install Linux

Here is the post about Step by Step installation of Debian 10 and Upgrading Debian 9 Stretch to Debian 10 Buster.

Proceed to the installation of AMP (Nginx v1.16, PHP-FPM v7.3, MariaDB v10.3) on Debian 10.

Install Nginx

Nginx is a free, open-source, high-performance web server. It is known for stability, rich feature set, simple configuration, and low resource consumption.

Install below packages.

sudo apt update

sudo apt install -y curl gnupg2 ca-certificates lsb-release

Download the Nginx repository signing key.


Add the Nginx key to the system.

sudo apt-key add nginx_signing.key

Add Nginx repository to the system.

echo "deb `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list

Install Nginx package using the following command.

sudo apt update

sudo apt install -y nginx

Start the Nginx service after the installation.

sudo systemctl start nginx

Open a web browser and visit the below URL.


You will get the welcome page that confirms that Nginx has been successfully installed and is up and running.

Install LEMP Stack on Debian 10 - Test Nginx Web Server
Install LEMP Stack on Debian 10 – Test Nginx Web Server

Nginx’s default document root on Debian 10 is /usr/share/nginx/html/. The configuration files are found under /etc/nginx/ directory.

Install MariaDB

MariaDB needs no introduction, and it is one of the most popular database server used for storing data.

Install the MariaDB server by running the following command.

sudo apt install -y mariadb-server mariadb-client

MariaDB service should be up and running at this moment. Check the status of MariaDB service using the below command.

sudo systemctl status mariadb

Next, make the MariaDB server secure by running the mysql_secure_installation command.

Install PHP

PHP-FPM is an alternative PHP FastCGI implementation, offers lots of features useful for websites of any size, especially busier sites.

Install php-fpm by issuing the following command.

sudo apt install -y php-fpm php-mysql php-cli

PHP-FPM listens on Unix socket by default. To make PHP-FPM use a TCP connection, edit the below file.

sudo nano /etc/php/7.3/fpm/pool.d/www.conf

Change the listen parameter.


listen = /run/php/php7.3-fpm.sock


listen =

Restart PHP-FPM service.

sudo systemctl restart php7.3-fpm

Create Virtual Host

Now, create a virtual host on Nginx server for the following details to test the LEMP stack.

Server Name: site.itzgeek.local
Document Root : /usr/share/nginx/html/site.itzgeek.local

Create a virtual host configuration file site.itzgeek.local.conf in /etc/nginx/conf.d/ directory.

sudo nano /etc/nginx/conf.d/site.itzgeek.local.conf

Add the following content.

server {
   server_name site.itzgeek.local;
   root /usr/share/nginx/html/site.itzgeek.local;

   location / {
       index index.html index.htm index.php;

   location ~ \.php$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/site.itzgeek.local$fastcgi_script_name;

Create the document root directory for the virtual host.

sudo mkdir /usr/share/nginx/html/site.itzgeek.local

Place a PHP file onto the document root.

echo "<?php phpinfo(); ?>" | sudo tee /usr/share/nginx/html/site.itzgeek.local/index.php

Restart the Nginx and PHP-FPM services.

sudo systemctl restart nginx

sudo systemctl restart php7.3-fpm

Test LEMP Stack

Go to any client system and create a host entry for your domain (site.itzgeek.local) in the /etc/hosts file to test the LEMP stack locally.

sudo nano /etc/hosts

A host entry will loo like below.             site.itzgeek.local

Open up your web browser on the client machine and type your domain name in the web address.


The page will look like below:

From the below screenshot, PHP is working through FPM/FastCGI, as shown in the Server API line.

Install LEMP Stack on Debian 10 - PHP Information
Install LEMP Stack on Debian 10 – PHP Information

You can also view the MariaDB support for PHP on the same page by scrolling the page down.

Install LEMP Stack on Debian 10 - MariaDB Support for PHP
Install LEMP Stack on Debian 10 – MariaDB Support for PHP


I hope this post helped you to install LEMP stack on Debian 10. Please share your feedback in the comments section.

You might also like