Skip to content
Open console

LEMP Stack

The LEMP stack (Linux, Nginx, MariaDB, and PHP) is a high-performance alternative to the classic LAMP stack. Nginx handles HTTP traffic more efficiently under load than Apache, making it a good choice for production web applications. This image runs the entire stack in Docker Compose for easy management.

ComponentVersion
NginxLatest stable
MariaDBLatest stable
PHP-FPM8.4
DockerLatest stable
Docker ComposeLatest stable
Ubuntu24.04 LTS

You can optionally set these when deploying LEMP from the marketplace. Leave any field blank to have a secure random value generated automatically.

VariableDescription
MARIADB_ROOT_PASSWORDDatabase root password
MARIADB_DATABASEName of the application database to create
MARIADB_USERApplication database username
MARIADB_PASSWORDApplication database user password
ssh ubuntu@<your-vm-ip>

On the first boot, a setup script runs automatically. It:

  • Generates random passwords for the MariaDB root and application users
  • Writes the environment configuration to /opt/lemp/.env
  • Saves credentials to /etc/lemp/credentials.txt
  • Starts the Nginx, PHP-FPM, and MariaDB containers via Docker Compose

This takes under 60 seconds. Track progress:

journalctl -u lemp-first-boot.service -f
sudo cat /etc/lemp/credentials.txt

This file contains the MariaDB root password and application database credentials. It is only readable by root.

cd /opt/lemp && docker compose ps

Open a browser and navigate to:

http://<your-vm-ip>

Place your PHP application files in the web root:

sudo cp -r my-app/* /opt/lemp/www/

Connect to MariaDB from within the stack:

cd /opt/lemp && docker compose exec mariadb mariadb -u root -p

All management is done via Docker Compose from /opt/lemp:

# Check status
docker compose ps
# Restart all services
docker compose restart
# View Nginx logs
docker compose logs nginx -f
# View PHP-FPM logs
docker compose logs php -f
# View MariaDB logs
docker compose logs mariadb -f
# Stop the stack
docker compose down
# Start the stack
docker compose up -d

Key paths:

PathPurpose
/opt/lemp/www/Web root
/opt/lemp/.envEnvironment variables (passwords)
/opt/lemp/nginx/Nginx configuration
/etc/lemp/credentials.txtCredentials reference

Port 80 is open by default. UFW is enabled.

After setting up HTTPS, restrict HTTP traffic:

sudo ufw allow 443/tcp
sudo ufw delete allow 80/tcp

Ask the ZCP docs

Type a question and pick an assistant. The assistant opens in a new tab and reads this page and the full ZCP documentation, so its answer comes from our docs.

Example questions

Ask with

Your question goes to the assistant you pick, under its own terms.