Nginx can be installed on Ubuntu and Debian in two ways: from the distribution's standard repository or from the official nginx.org repository. The difference is version and update speed. On VDS and dedicated servers at ZevsHost.net, administrators usually pick the second option when they need fresh features like HTTP/3.
Which Nginx version to install
The Ubuntu and Debian repository contains the version that shipped with the distribution at release time and is barely updated until the next LTS. The official nginx.org repository ships a fresh mainline or stable release and updates regularly.
For most hosted sites, the distribution version is fine: it is battle-tested and receives security patches. For HTTP/3, QUIC, and newer modules you need the official repository — read more in the article on HTTP/2 and HTTP/3 in Nginx.
Installing Nginx from the standard repository
The fastest path is installing the nginx package from the distro repository. The command is the same for Ubuntu and Debian:
sudo apt update
sudo apt install nginx -y
sudo systemctl enable --now nginx
After installation Nginx starts immediately and listens on port 80. If Apache is already running on the server, the port conflict raises the error bind() to 0.0.0.0:80 failed — stop Apache first with sudo systemctl stop apache2.
Adding the official nginx.org repository
To get the latest version, add the nginx.org repository and its GPG key:
sudo apt install curl gnupg2 ca-certificates lsb-release -y
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update
sudo apt install nginx -y
For Debian, replace ubuntu in the package path with debian, and replace the Ubuntu codename with your Debian release codename. After sudo apt update, the system should pick the package from the new source instead of the distro repository.
Verifying the install and first launch
After installing either way, check the version, configuration syntax, and service status:
- nginx -v — shows the installed version.
- nginx -V — shows the version and the list of build modules.
- nginx -t — checks configuration syntax without restarting.
- systemctl status nginx — shows whether the service is running.
Open the server IP in a browser: the Welcome to nginx! page confirms a successful install. Next, replace the default config with your own server block, as described in the article on Nginx virtual hosts.
Table: distro repository versus official repository
| Parameter | Ubuntu/Debian repository | Official nginx.org |
|---|---|---|
| Nginx version | Fixed at the distro release | Updated regularly |
| HTTP/3 and QUIC | Often missing | Available in fresh builds |
| Security patches | Arrive via distro apt | Arrive directly from nginx.org |
| Configuration API stability | High, few changes | New directives possible |
What else to install next to Nginx
A bare web server rarely works alone. A typical PHP site needs a few more components:
- PHP-FPM and its configuration — see the article on configuring and optimizing PHP-FPM.
- A MySQL or MariaDB database to store site data.
- The full LEMP stack is described end to end in the article how to install LEMP.
- An SSL certificate for HTTPS — without one, modern browsers flag the site as unsafe.
If nginx -t returns an error after apt install nginx, and systemctl status nginx shows failed, the cause is almost always a busy port 80 or a syntax error in /etc/nginx/nginx.conf. Check the command output before moving to the next step: creating your first site.