How to install Nginx on Ubuntu 20.04
Nginx is an open source software for web serving. It uses single-threaded architecture and is designed for maximum performance and stability, so it is more efficient than Apache if configured correctly. In addition to HTTP server capabilities, NGINX can also act as a proxy server for email (POP3, SMTP, …), a load balancer and reverse proxy for HTTP, TCP and UDP servers.
Step 1: Install Nginx
Since Nginx is available in the Ubuntu repositories, you can directly install Nginx using the
aptpackage management and installation system.
First, proceed to update the packages in the system:
sudo apt install -y update
Install Nginx for your Ubuntu server:
sudo apt install -y nginx
Check Nginx version:
sudo nginx -v
nginx version: nginx/1.17.10 (Ubuntu)
Allow Nginx to start on system:
sudo systemctl enable nginx
Start and check the status of the Nginx service:
systemctl start nginx
systemctl status nginx
Step 2: Configure the firewall
Use ufw to know how to use the firewall configuration for Nginx :
sudo ufw app list
Please note: If an error occurs” sudo: ufw: command not found ” .you can fix the error by running the following command to install ufw then try again:
sudo apt-get install ufw
You can enable ufw by typing the following command :
sudo ufw enable
Output will have the following:
You see that for nginx, there are 3 possible configurations to configure for nginx, but currently I do not have a configuration to use SSL for the website, so I only allow traffic to go through port 80.
Enable the above using the following command:
sudo ufw allow 'Nginx HTTP'
Then check the change again with the following command:
sudo ufw status
Step 3: Check the website
You will be redirected to the default Nginx web page:
When you show this, it is successfully installed and nginx is ready to be managed.
Nginx with many extended features can be a great application for your system. In this tutorial, I have shown you how to install Nginx for Ubuntu 20.04