This post shows students and new users the steps to install, configure, and use the Nginx HTTP web server on Ubuntu Linux. Nginx is probably the second most popular open source web server in the world. Most likely, many of the websites you visit today are running the Nginx HTTP server.
If you are thinking of running a website, you are more likely to choose Nginx or have Nginx support from web hosting companies than from other web servers. Nginx provides powerful features that can be extended by a wide variety of modules.
If you are a student or a new user learning Linux, the easiest place to start learning is on Ubuntu Linux. Ubuntu is the modern open source Linux operating system for desktops, servers, and other devices.
To start installing the Nginx HTTP server on Ubuntu Linux, follow the steps below.
How to use the Nginx HTTP server on Ubuntu Linux
As mentioned above, Nginx is widely used on the internet. If you want to learn how to install and use it on Ubuntu Linux, continue below.
Nginx is available in the Ubuntu repositories, so we can easily install it using the suitable package management tool.
To install Nginx, run the following commands:
sudo apt update sudo apt install nginx
The above commands will install the Nginx HTTP server.
Now to find out if Nginx is actually installed and running, use the health check command below.
sudo systemctl status nginx
The command will generate similar lines below when Nginx is running.
How to allow Nginx through the Ubuntu firewall
If you are running Ubuntu in protected mode with the firewall enabled, you will have to allow HTTP (80) and HTTPS (443) to the Nginx web server. In most cases, the Ubuntu server runs without the firewall enabled. However, run the following commands if you are unsure.
If you are using UFW to manage the Ubuntu firewall, run the following commands to allow traffic.
sudo ufw allow 'Nginx Full'
That will allow full traffic to Nginx.
With the firewall open, simply look up the server’s hostname or IP address to see if the default Nginx page is active.
You should see the default Nginx welcome page.