How did I install Nginx from APT to Debian 10?

Step 1

Install the prerequisites

nginx.org/en/linux_packages.html#Debian

apt install curl gnupg2 ca-certificates lsb-release

Step 2

To set up the apt repository for stable nginx packages, run the following command:

nginx.org/en/linux_packages.html#Debian

echo "deb http://nginx.org/packages/debian `lsb_release -cs` nginx" >> /etc/apt/sources.list

Step 3

Set up repository pinning to prefer our packages over distribution-provided ones:

nginx.org/en/linux_packages.html#Debian

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | sudo tee /etc/apt/preferences.d/nginx

Step 4

Next, import an official nginx signing key so apt could verify the packages authenticity. Fetch the key:

nginx.org/en/linux_packages.html#Debian

curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key

Step 5

Verify that the downloaded file contains the proper key:

nginx.org/en/linux_packages.html#Debian

gpg --dry-run --quiet --import --import-options import-show /tmp/nginx_signing.key

01

Step 6

Finally, move the key to apt trusted key storage (note the "asc" file extension change):

nginx.org/en/linux_packages.html#Debian

mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx.asc