How did I install Nginx from APT to Debian 10?

Step 1

Install the prerequisites

apt install curl gnupg2 ca-certificates lsb-release

Step 2

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

echo "deb `lsb_release -cs` nginx" >> /etc/apt/sources.list

Step 3

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

echo -e "Package: *\nPin: origin\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:

curl -o /tmp/nginx_signing.key

Step 5

Verify that the downloaded file contains the proper key:

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


Step 6

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

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