Skip to content

Instantly share code, notes, and snippets.

@7x7
Last active July 11, 2019 10:07
Show Gist options
  • Save 7x7/dc25621e16a629f1796a1bbc5d56b74f to your computer and use it in GitHub Desktop.
Save 7x7/dc25621e16a629f1796a1bbc5d56b74f to your computer and use it in GitHub Desktop.
Install Nginx on Ubuntu. e.g., Ubuntu18.04 x64, Nginx1.17.1

Nginx

Installation

Install the prerequisites:

$ sudo apt install curl gnupg2 ca-certificates lsb-release

Adding the Nginx APT Repository

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

$ echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
 | sudo tee /etc/apt/sources.list.d/nginx.list

If you would like to use mainline nginx packages, run the following command instead:

$ echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
 | sudo tee /etc/apt/sources.list.d/nginx.list

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

$ curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

Verify that you now have the proper key:

$ sudo apt-key fingerprint ABF5BD827BD9BF62

The output should contain the full fingerprint 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 as follows:

pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
      573B FD6B 3D8F BC64 1079  A6AB ABF5 BD82 7BD9 BF62
uid   [unknown] nginx signing key <[email protected]>

Installing Nginx with APT

To install nginx, run the following commands:

$ sudo apt update
$ sudo apt install nginx

Test your installation

$ nginx -v
nginx version: nginx/1.17.1

Reference

https://nginx.org/en/linux_packages.html

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