[2 min installs] Nginx on Ubuntu

Better Stack Team
Updated on August 30, 2022

Here is how to install Nginx on Ubuntu 20.04 in under two minutes:

Step 1 - Update the package list on your system

The first step is to update the package list on your system before proceeding to actual installation:

sudo apt update -y
Copied!

apt update downloads the package lists from the repositories and updates them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs.

Step 2 - Install Nginx

Now, install nginx package using the apt install command:

sudo apt install nginx
Copied!

Step 3 - Adjust the firewall

We are not done quite yet. Now you need to adjust the firewall to allow web traffic.

sudo ufw allow 'Nginx HTTP'
Copied!

Final steps

Now, everything is installed and ready to go.

To test if the service is running, execute the following command:

systemctl status nginx
Copied!

To stop the service, execute this command:

sudo systemctl stop nginx
Copied!

To start the service, execute this command

sudo systemctl start nginx
Copied!

That’s it

You successfully installed Nginx on your system. You can go ahead and type your server's IP into the browser to see the default Nginx page (if the server is running).

Check Uptime, Ping, Ports, SSL and more.
Get Slack, SMS and phone incident alerts.
Easy on-call duty scheduling.
Create free status page on your domain.
Got an article suggestion? Let us know
Next article
[2 min installs] Apache on Ubuntu
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.