Debian
sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring
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/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update
sudo apt install nginx
systemctl enable nginx
You’re on nginx 1.24.0, which is the version Ubuntu 24.04 (Noble) ships by default. To get a newer version, you need to switch to the official nginx.org repository — Ubuntu’s repos won’t move past 1.24.0. Latest versions available
Stable: 1.30.4 (recommended for production)
Mainline: 1.31.4 (newer features, more frequent updates)
Step-by-step upgrade
sudo cp -r /etc/nginx /etc/nginx.backup.$(date +%Y%m%d)
sudo apt update sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
| 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]
https://nginx.org/packages/ubuntu $(lsb_release -cs) nginx”
| sudo tee /etc/apt/sources.list.d/nginx.list
For mainline (latest features): bash
echo “deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg]
https://nginx.org/packages/mainline/ubuntu $(lsb_release -cs) nginx”
| sudo tee /etc/apt/sources.list.d/nginx.list
echo -e “Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n”
| sudo tee /etc/apt/preferences.d/99nginx
sudo apt update sudo apt install nginx
nginx -v
sudo nginx -t sudo systemctl reload nginx