Install Nginx on Debian 12

Overview

Nginx is the world’s most popular web server. This guide covers installation, virtual host configuration, and basic security hardening on Debian 12. Running Nginx on a solid VPS matters — Contabo (affiliate) gives you NVMe-backed servers with plenty of bandwidth for web hosting from $5.50/month.

Full guideNginx Web Server on Debian 12


Step 1 — Install Nginx

1
2
3
apt update
apt install nginx -y
systemctl enable --now nginx

Step 2 — Configure a Virtual Host

1
nano /etc/nginx/sites-available/example.com
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/example.com;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}
1
2
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

Step 3 — Open Firewall Port

1
ufw allow 'Nginx Full'

🖥️ Check Them Out — Contabo Hosting

Nginx performs best on fast hardware. Contabo delivers serious VPS and dedicated server specs at prices that don’t hurt — perfect for self-hosting your sites and apps.

  • VPS — 4 vCPUs, 8 GB RAM, 100 GB NVMe from ~$5.50/mo → great for most Nginx setups
  • Dedicated — 6-core bare metal, no noisy neighbours → ideal for high-traffic production

→ Check Out Contabo VPS (affiliate link)   → Check Out Contabo Dedicated Servers (affiliate link)