How to Install LEMP Stack on Debian 13 (Trixie)
LEMP is a combination of free, open source software. The acronym LEMP refers to the first letters of Linux (Operating system), Nginx Server, MySQL (database software), and PHP, PERL or Python, principal components to build a viable general purpose web server.
Installing Nginx Web Server
To install the Nginx package, run the below command,
apt update
apt install nginx
Output:
root@server:~# apt update
apt install nginx
Get:1 http://security.debian.org/debian-security trixie-security InRelease [43.4 kB]
Get:2 http://deb.debian.org/debian trixie InRelease [168 kB]
Get:3 http://deb.debian.org/debian trixie-updates InRelease [45.1 kB]
Get:4 http://deb.debian.org/debian trixie/non-free-firmware Sources.diff/Index [27.8 kB]
Get:5 http://deb.debian.org/debian trixie/main Sources.diff/Index [27.9 kB]
Get:6 http://deb.debian.org/debian trixie/main amd64 Packages.diff/Index [27.9 kB]
Get:7 http://deb.debian.org/debian trixie/main Translation-en.diff/Index [27.9 kB]
Get:8 http://deb.debian.org/debian trixie/non-free-firmware amd64 Packages.diff/Index [27.8 kB]
Get:9 http://deb.debian.org/debian trixie/non-free-firmware Sources 2025-07-25-1404.44.pdiff [295 B]
Get:10 http://deb.debian.org/debian trixie/non-free-firmware Sources 2025-07-29-1404.42.pdiff [469 B]
Get:10 http://deb.debian.org/debian trixie/non-free-firmware Sources 2025-07-29-1404.42.pdiff [469 B]
Get:11 http://deb.debian.org/debian trixie/main Sources 2025-07-24-2010.11.pdiff [316 B]
Get:12 http://deb.debian.org/debian trixie/main Sources 2025-07-25-0204.56.pdiff [3,509 B]
Get:13 http://deb.debian.org/debian trixie/main Sources 2025-07-25-1404.44.pdiff [12.2 kB]
Get:14 http://deb.debian.org/debian trixie/main Sources 2025-07-25-2004.14.pdiff [329 B]
Get:15 http://deb.debian.org/debian trixie/main Sources 2025-07-26-0204.24.pdiff [11.9 kB]
Get:16 http://deb.debian.org/debian trixie/main Sources 2025-07-26-1418.34.pdiff [65 B]
Get:17 http://deb.debian.org/debian trixie/main Sources 2025-07-26-2004.33.pdiff [741 B]
Get:18 http://deb.debian.org/debian trixie/main Sources 2025-07-27-0204.35.pdiff [3,055 B]
Once the Nginx installation is complete, check the status of Nginx using the following systemctl command.
systemctl status nginx
Output:
root@server:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: en>
Active: active (running) since Sat 2025-08-02 13:02:19 EDT; 2min 38s ago
Invocation: fe1238ab3f44410d8ecbf628556fa4c0
Docs: man:nginx(8)
Process: 1404 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proce>
Process: 1406 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (c>
Main PID: 1434 (nginx)
Tasks: 3 (limit: 7052)
Memory: 3.1M (peak: 7.1M)
CPU: 158ms
CGroup: /system.slice/nginx.service
├─1434 "nginx: master process /usr/sbin/nginx -g daemon on; master>
├─1436 "nginx: worker process"
└─1437 "nginx: worker process"
Check if Nginx is properly installed by opening a browser and navigating to URL http://SERVER_IP/
http://SERVER_IP/
Replace Server_IP with actual IP address of the server.
If nginx has been installed and is running successfully, you will see the following message on your browser.

Installing MariaDB
We need to install a database system to be able to store and manage data for your website.
To install MariaDB, use the following command,
apt install mariadb-server
Output:
root@server:~# apt install mariadb-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
galera-4 gawk mariadb-client mariadb-common mariadb-server-core mysql-common
The following NEW packages will be installed:
galera-4 gawk mariadb-client mariadb-common mariadb-server mariadb-server-core mysql-common
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Once the Mariadb-server installation is complete, check the status of mariadb using the following systemctl command.
systemctl status mariadb
Output:
root@server:~# systemctl status mariadb
● mariadb.service - MariaDB 11.8.2 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: >
Active: active (running) since Sat 2025-08-02 13:07:28 EDT; 24s ago
Invocation: 1ce3584201f44a7082913489cdbae9fa
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 2470 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var>
Process: 2472 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && >
Process: 2539 ExecStartPost=/bin/rm -f /run/mysqld/wsrep-start-position (co>
Process: 2541 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/>
Main PID: 2525 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 15 (limit: 46545)
Memory: 124M (peak: 128.6M)
CPU: 4.766s
CGroup: /system.slice/mariadb.service
└─2525 /usr/sbin/mariadbd
Manually Secure the installation
Login to MariaDB
mysql -u root
Set root password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_secure_password';
Remove anonymous users
DELETE FROM mysql.user WHERE User='';
Disallow remote root login
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
Remove test database
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
Reload privileges
FLUSH PRIVILEGES;
EXIT;
Installing PHP-FPM (Fast Process Manager)
To install PHP-FPM version 8.4 and a PHP module to communicate with a MariaDB/MySQL database system.
apt install php-fpm php-mysql
Output:
root@server:~# apt install php-fpm php-mysql
Installing:
php-fpm php-mysql
Installing dependencies:
libargon2-1 php-common php8.4-common php8.4-mysql php8.4-readline
libsodium23 php8.4-cli php8.4-fpm php8.4-opcache
Suggested packages:
php-pear
Summary:
Upgrading: 0, Installing: 11, Removing: 0, Not Upgrading: 36
Download size: 5,260 kB
Space needed: 24.8 MB / 18.2 GB available
Continue? [Y/n] y
Get:1 http://deb.debian.org/debian trixie/main amd64 libargon2-1 amd64 0~20190702+dfsg-4+b2 [21.4 kB]
Get:2 http://deb.debian.org/debian trixie/main amd64 libsodium23 amd64 1.0.18-1+b2 [165 kB]
Get:3 http://deb.debian.org/debian trixie/main amd64 php-common all 2:96 [13.3 kB]
Once the PHP-FPM installation is complete, check the status of PHP-FPM using the following systemctl command.
systemctl status php8.4-fpm
Output:
root@server:~# systemctl status php8.4-fpm
● php8.4-fpm.service - The PHP 8.4 FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php8.4-fpm.service; enabled; prese>
Active: active (running) since Sat 2025-08-02 13:14:38 EDT; 2min 9s ago
Invocation: 7943cf08718840f896347c2596be4321
Docs: man:php-fpm8.4(8)
Process: 9862 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run>
Main PID: 9859 (php-fpm8.4)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0.00>
Tasks: 3 (limit: 7052)
Memory: 9.8M (peak: 11.6M)
CPU: 182ms
CGroup: /system.slice/php8.4-fpm.service
├─9859 "php-fpm: master process (/etc/php/8.4/fpm/php-fpm.conf)"
├─9860 "php-fpm: pool www"
└─9861 "php-fpm: pool www"
Secure PHP-FPM by modifying the configuration file:
vi /etc/php/8.4/fpm/php.ini
Uncomment and change the following line:
cgi.fix_pathinfo=0
Modify default Nginx configuration file:
vi /etc/nginx/sites-available/default
Ensure this section is active:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
}
Test Nginx config:
nginx -t
Output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart services:
systemctl restart php8.4-fpm
systemctl restart nginx
Testing PHP-FPM Processing on Nginx
Create a test PHP file:
echo "<?php phpinfo(); ?>" | tee /var/www/html/info.php
Open browser:
http://SERVER_IP/info.php
You should see a page similar to the one below:

Done!
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS