Install Latest Nginx on Ubuntu

Install the latest version of Nginx on Ubuntu


Before Starting

Supported Installation

This installation procedure is tested on Ubuntu 22.04.x LTS with x86_64 architecture, but should be compatible with other version of Ubuntu.

Installation

Install dependencies

sudo apt install curl gpg

Add gpg key

curl https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/nginx_signing.gpg

Setup apt source list

printf "deb [signed-by=/etc/apt/trusted.gpg.d/nginx_signing.gpg] https://nginx.org/packages/ubuntu $(lsb_release -cs) nginx\ndeb-src [signed-by=/etc/apt/trusted.gpg.d/nginx_signing.gpg] https://nginx.org/packages/ubuntu $(lsb_release -cs) nginx\n" | sudo tee /etc/apt/sources.list.d/nginx.list

Install Nginx

sudo apt update && sudo apt install nginx

Finishing

Start Nginx

sudo systemctl start nginx