Nginx is one of the most famous & widely used web servers. Nginx not only acts as a web server but can also work as a mail proxy server, reverse proxy, cache server as well as a load balancer.

In this tutorial, we will learn how to install NGINX on Ubuntu using the Ubuntu system repositories & also with using Nginx repositories.

Recommended Read: How to install Nginx on CentOS/RHEL

Also Read: Localhost – Setup your own Web Server

So let’s get start.

Install Nginx on Ubuntu using the Ubuntu repositories

nginx is maintained on the default Ubuntu repositories & can be installed with the default package manager i.e. apt. To install Nginx on Ubuntu, run the following command,

$ sudo apt update && sudo apt upgrade -y

$ sudo apt install nginx

Once the nginx is installed, the nginx service will install by default. We can check it by running the following command,

$ systemctl status nginx


$ ps -ef | grep nginx

If it’s not running, we can start the server by the following command,

$ systemctl start nginx

To enable the nginx service at the boot time, execute the following command,

$ systemctl enable nginx

Once the webserver is up and running, we can also access the default webpage for Nginx. All we need is the system IP address or if you are trying to access the webpage on the localhost, then we can also access the webpage with either ‘localhost’ or ‘’ as the URL.




Install Nginx using the Official Nginx Repositories

To install the official nginx repositories, we need to first install the keys that are used to sign the NGINX packages,

$ sudo wget

$ sudo apt-key add nginx_signing.key

Next, we will add the repositories in the file ‘/etc/sources.list’,

$ vim /etc/sources/list 

deb <CODENAME> nginx

deb-src <CODENAME> nginx

Here, <CODENAME> refers to the code the Ubuntu version being used, list is mentioned below,

Trusty 14.04 LTS
Utopic 14.10
Vivid 15.04
Wily 15.10
Xenial 16.04
Yakkety 16.10
Zesty 17.04
Artful 17.10
Bionic 18.04
Cosmic 18.10
Disco 19.04
Eoam 19.10
Focal 20.04
Groovy 20.10


So for Ubuntu 20.04, we need to add the following entries to ‘/etc/sources.list’,

deb groovy nginx

deb-src groovy nginx

Once done, save the file & exit & run the following command to install nginx on Ubuntu,

$ sudo apt update && sudo apt upgrade

$ sudo apt install nginx

Check the Nginx service & access the webserver to access the default webpage. So this completes our tutorial on how to install Nginx on Ubuntu. In our next tutorial, we will discuss how we can create the webserver blocks to host multiple websites on a single Nginx webserver.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.