Skip to content

Instantly share code, notes, and snippets.

@craigvantonder
Last active March 29, 2021 14:14
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save craigvantonder/729fc169ae087918e6de744f420adf8b to your computer and use it in GitHub Desktop.
Save craigvantonder/729fc169ae087918e6de744f420adf8b to your computer and use it in GitHub Desktop.
Install Nginx Mainline / Stable on Ubuntu 16.04
#!/bin/bash
# https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
# Switch to root
sudo su
# Add the mainline release
echo "deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx" > /etc/apt/sources.list.d/nginx.list
# Or add the stable release
#echo "deb http://nginx.org/packages/ubuntu/ xenial nginx
#deb-src http://nginx.org/packages/ubuntu/ xenial nginx" > /etc/apt/sources.list.d/nginx.list
# Install the packages
apt-get -y update
apt-get -y install nginx
# Check the Nginx version
nginx -v
@gvsmirnov
Copy link

If you are getting this error:

W: GPG error: http://nginx.org/packages/mainline/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62
W: The repository 'http://nginx.org/packages/mainline/ubuntu xenial InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Then you need to add the nginx gpg key to the apt keystore, e.g.:

wget https://nginx.org/keys/nginx_signing.key -O - | sudo apt-key add -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment