Updated: 28 September 2026 · Applies to: Debian 12
Debian 9 and 10 are no longer supported, so this guide now uses Debian 12 (Ubuntu 24.04 works the same way).
Building Nginx from source lets you add modules that are not in the distribution's package. For most servers, the packaged Nginx (or nginx.org's official repository) is easier to keep secure.
Build
apt install build-essential libpcre2-dev zlib1g-dev libssl-dev cd /usr/local/src curl -O https://nginx.org/download/nginx-1.28.0.tar.gz # use the current stable version from nginx.org tar xzf nginx-1.28.0.tar.gz && cd nginx-1.28.0 ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf \ --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module make && make install
Run it with systemd
Create /etc/systemd/system/nginx.service (the nginx.org packages include a good example), then systemctl daemon-reload && systemctl enable --now nginx.
Note: A self-built Nginx is not updated by apt. Watch nginx.org security announcements and rebuild when needed.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
