Skip to content

Instantly share code, notes, and snippets.

@promisepreston
Last active December 11, 2019 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save promisepreston/724c4f12afc0919f0fe9d6f20ce9ae96 to your computer and use it in GitHub Desktop.
Save promisepreston/724c4f12afc0919f0fe9d6f20ce9ae96 to your computer and use it in GitHub Desktop.

Install and Setup Nginx on Ubuntu 18.04

Install the Prerequisites

sudo apt install curl gnupg2 ca-certificates lsb-release

Set up the Apt Repository

Do not set up the apt repository for stable nginx packages by running the following command below if your architecture is amd64 (64 bit):

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

As you will run into this error:

N: Skipping acquire of configured file 'nginx/binary-i386/Packages' as repository 'http://nginx.org/packages/ubuntu bionic InRelease' doesn't support architecture 'i386'

To check the architecture of your Ubuntu machine, simply run the command below: uname -a

The shortened copy of expected response for 32 and 64 bit achitectures should be like this:

1. Linux Preston-PC 5.0.0-31-generic i686 athlon i386
   # for 32 Bit architecture
2. Linux Preston-PC 5.0.0-31-generic x86_64 x86_64 x86_64
   # for 64 Bit Architecture

Import Official Nginx Signing Key

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 <signing-key@nginx.com>

Install Nginx

To install nginx, run the following commands:

sudo apt update
sudo apt install nginx

Start Nginx Service

We can start, stop, monitor and restart nginx service with the systemd init system by running the command below:

sudo systemctl start nginx
sudo systemctl status nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx

References

  1. How To Install Nginx on Ubuntu 18.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment