How to Install the Latest Nginx Version 1.27 on Debian 12 bookworm

Published January 22, 2025

The default version of Nginx that comes bundled with Debian 12 bookworm or 11 bullseye is version 1.22, which is outdated.

This blog post shows how to install the latest Nginx version from its official mainline repository. As of January 21, the latest Nginx version is 1.27.

How to install the latest Nginx mainline on Debian 12 How to install the latest Nginx mainline on Debian 12

There are two ways of installing Nginx.

  • Using the official Nginx repository
  • Using Sury repository

Installing Nginx from the official Nginx repository

This is a two-step process.

  1. First, download and add the Nginx GPG key to verify the authenticity of the packages we will download and install.
  2. Second, we will add the Nginx repository to our apt package manager list.

Download and add Nginx GPG key

Run these commands to download and add the Nginx GPG key.

curl -fSsL https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg > /dev/null

Validate the GPG key

gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

Add the Nginx repository to sources.list

Run these commands to add the Nginx repository to sources.list.

echo "deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list

Install Nginx

Now, install Nginx with apt install:

sudo apt update
sudo apt install nginx

Verify Nginx version

After the installation is completed, verify the Nginx version.

sudo nginx -v

You should get something like this:

Output:

nginx version: nginx/1.27.3

Installing Nginx from Sury Nginx repository

Ondrej Sury maintains Nginx, PHP and other repositories that I use regularly. His version contains additional compiled modules, one of which uses Brotli.

You can either use the Nginx Mainline or Nginx stable.

To use the Nginx Mainline repository, run this:

curl -sSL https://packages.sury.org/nginx-mainline/README.txt | sudo bash -x

To use the Nginx stable repository, run this:

curl -sSL https://packages.sury.org/nginx/README.txt | sudo bash -x

Both these commands run everything including apt update, add the repositories to sources.list, etc. The last line in that script is apt update, so we will not have to run it before doing apt install.

Install Nginx

Now, install Nginx with apt install:

sudo apt install nginx

Verify Nginx version

After the installation is completed, verify the Nginx version.

sudo nginx -v

You should get something like this:

Output:

nginx version: nginx/1.27.3

Conclusion

I hope the installation process for getting the latest Nginx version has worked for you. If you are stuck somewhere or have suggestions, please add them in the comments below, or send me an email. Thanks for reading.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Last Updated: January 22, 2025.     This post was originally written on June 30, 2009.