It’s been a minute since I’ve built out a new server, specifically a web server.
As I ventured down the path of installing the latest version of nginx
recently, I found the official documentation to be a touch lacking. The steps
were clear enough, but the installation guide didn’t mention setting up the GPG
signing key.
A bit of additional research yielded another official document that talked about
the key and I thought it wouldn’t be a bad idea to document the installation
steps in their entirety so future Josh doesn’t have to track down the signing
key stuff again.
Worth noting, the following commands should be run as a super user.
For Debian 8.x, 9.x and 10.x+
Step 1: Add the source repository.
Be sure to replace codename with the code name for the version of Debian
you’re running.
- Debian 8.x:
jessie
- Debian 9.x:
stretch
- Debian 10.x:
buster
Most likely will work for future versions of Debian past buster
.
cat <<EOF >> /etc/apt/sources.list.d/nginx.list
deb http://nginx.org/packages/debian/ codename nginx
deb-src http://nginx.org/packages/debian/ codename nginx
EOF
Step 2: Add the signing key.
curl -L https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
Step 3: Update the package sources.
apt update
Step 4: Install or upgrade nginx
.
# If nginx is not already installed
apt install nginx
# If nginx is already installed
apt upgrade
For Ubuntu 14.04 LTS, 16.04 LTS, 18.04 LTS, 18.10 and 19.04+
Step 1: Add the source repository.
Be sure to replace codename with the code name for the version of Ubuntu
you’re running.
- Ubuntu 14.04 LTS:
trusty
- Ubuntu 16.04 LTS:
xenial
- Ubuntu 18.04 LTS:
bionic
- Ubuntu 18.10:
cosmic
Most likely will work for future versions of Ubuntu past cosmic
.
cat <<EOF >> /etc/apt/sources.list.d/nginx.list
deb http://nginx.org/packages/ubuntu/ codename nginx
deb-src http://nginx.org/packages/ubuntu/ codename nginx
EOF
Step 2: Add the signing key.
curl -L https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
Step 3: Update the package sources.
apt update
Step 4: Install or upgrade nginx
.
# If nginx is not already installed
apt install nginx
# If nginx is already installed
apt upgrade