Docs / App Marketplace / Deploying a LEMP Stack Application

Deploying a LEMP Stack Application

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 27 views · 1 min read

What is LEMP?

LEMP stands for Linux, Nginx (Engine-X), MySQL/MariaDB, and PHP. It is the most popular stack for hosting PHP applications and provides better performance than the traditional LAMP stack for most workloads.

Install Components

sudo apt update
sudo apt install -y nginx mariadb-server php8.2-fpm php8.2-mysql \
  php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip

Configure Nginx for PHP

Edit /etc/nginx/sites-available/default:

server {
    listen 80;
    server_name example.com;
    root /var/www/html;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }

    location ~ /\. {
        deny all;
    }
}

Secure MariaDB

sudo mysql_secure_installation

Create a Database

sudo mysql -u root
CREATE DATABASE myapp;
CREATE USER 'myapp'@'localhost' IDENTIFIED BY 'secure_pass';
GRANT ALL ON myapp.* TO 'myapp'@'localhost';
FLUSH PRIVILEGES;

Test PHP

echo "<?php phpinfo();" | sudo tee /var/www/html/info.php
# Visit http://your-ip/info.php
# Delete after testing:
sudo rm /var/www/html/info.php

Was this article helpful?