Install Nginx on Debian

Contents
Which version you get
Install
The service
Check that Nginx answers
Open the firewall with ufw
Modules
Next steps
Remove Nginx

Debian packages Nginx in its main repository, so the install takes one apt command and the service runs right after it. The outputs come from fresh containers of Debian 13 and 12, checked on 26 October 2026, and one older output from Debian 10 is marked as such. The other distributions are in Install Nginx on Linux.

Which version you get

Debian keeps the Nginx version for the life of a release and adds only fixes; their count is the part after the dash:

ReleasePackage version
Debian 13 (trixie)1.26.3-3+deb13u10
Debian 12 (bookworm)1.22.1-9+deb12u10
Debian 10 (buster)1.14.2-2+deb10u1

For newer versions use the packages from nginx.org, see Newer versions from nginx.org.

Install

Refresh the package lists and see which version apt would install:

sudo apt update

apt-cache policy nginx

nginx: Installed: (none) Candidate: 1.26.3-3+deb13u10

Install:

sudo apt install nginx

The last lines of the output on Debian 13:

… Setting up nginx-common (1.26.3-3+deb13u10) ... Setting up nginx (1.26.3-3+deb13u10) ...

Debian 12 and 13 install two packages, nginx and nginx-common. Older releases pulled in a full build with many modules; on Debian 10 the output listed

The following NEW packages will be installed: libnginx-mod-http-auth-pam libnginx-mod-http-dav-ext libnginx-mod-http-echo libnginx-mod-http-geoip libnginx-mod-http-image-filter libnginx-mod-http-subs-filter libnginx-mod-http-upstream-fair libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream nginx nginx-common nginx-full

The service

The package starts Nginx and enables it at boot. Check the state with systemctl:

systemctl status nginx

The line Active: active (running) means it runs, and enabled in the line Loaded means it starts at boot. If you turned it off once, enable it again:

sudo systemctl enable nginx

Check that Nginx answers

nginx -v

nginx version: nginx/1.26.3

Ask the start page for its headers with curl:

curl -I http://localhost/

HTTP/1.1 200 OK Server: nginx Date: Mon, 26 Oct 2026 09:14:34 GMT Content-Type: text/html Content-Length: 615 Last-Modified: Mon, 26 Oct 2026 09:14:10 GMT Connection: keep-alive ETag: "6adf19e2-267" Accept-Ranges: bytes

Debian 13 sends Server: nginx without the version, because its nginx.conf turns the version off:

grep -n server_tokens /etc/nginx/nginx.conf

22: server_tokens off; # Recommended practice is to turn this off

On Debian 12 the line is commented out, and the header says Server: nginx/1.22.1. Remove the # there to hide the version as well.

Open the firewall with ufw

Debian turns on no firewall by itself. If you use ufw, install it; the Nginx package has already added its profiles:

sudo apt install ufw

sudo ufw app list | grep Nginx

Nginx Full Nginx HTTP Nginx HTTPS Nginx QUIC

Nginx QUIC, for HTTP/3, is new in Debian 13; Debian 12 lists the other three. What a profile opens:

sudo ufw app info 'Nginx Full'

Profile: Nginx Full Title: Web Server (Nginx, HTTP + HTTPS) Description: Small, but very powerful and efficient web server Ports: 80,443/tcp

Allow SSH first, so that switching ufw on does not cut your own connection, then the web ports, then switch it on:

sudo ufw allow SSH

sudo ufw allow 'Nginx Full'

sudo ufw enable

Modules

The modules that are not built into the binary come as packages named libnginx-mod-…. On Debian 12 and 13 none is installed, so this folder is empty:

/etc/nginx/modules-enabled/

Installing such a package puts a file there that loads the module; test the configuration and reload Nginx afterwards.

Next steps

The configuration is /etc/nginx/nginx.conf, the default site serves /var/www/html, and each site gets a file in sites-available with a link in sites-enabled. All of this, step by step: nginx.conf: configuration and sites.

Remove Nginx

remove keeps the configuration:

sudo apt remove nginx

purge of both packages also deletes /etc/nginx and the logs in /var/log/nginx; /var/www stays:

sudo apt purge nginx nginx-common

Article authors: Andrei Olegovich, Klavdiya Kondakova

Related articles
Install Nginx
Install Nginx on Linux
Install Nginx on Ubuntu
nginx.conf: configuration and sites
Debian

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: