How to Install NGINX Web Server in Ubuntu

In this tutorial, you will learn how to Install and Configure Nginx Web Server in Ubuntu. Nginx web server is a widely used open-source HTTP server for modern operating systems including UNIX and Windows.
How to install and configure the Nginx web server in Ubuntu systems.
Step 1: Updating Repositories
You can download and update the latest repositories in ubuntu. Open the terminal or login using SSH and run the following command
sudo apt update
Step 2: Install Nginx Server
Run the following command to install the Nginx webserver.
sudo apt install nginx
Step 3: Configure the Firewall
Run the following command to check the ufw application profiles
sudo ufw app list
Output:
Available applications: Nginx Full Nginx HTTP Nginx HTTPS OpenSSH
you can see in the output, Three profiles are available in Nginx
- Nginx Full: This profile opens both port 80 (unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic).
- Nginx HTTP: This profile opens only port 80 (unencrypted web traffic)
- Nginx HTTPS: This profile opens only port 443 (secure encrypted web traffic).
To allow non HTTP traffic to your Nginx server run the following command.
Note: If you are installing Nginx server in AWS Ubuntu server do not run the following command, You just need to add port 80 in inbound rule in security groups.
sudo ufw allow ‘Nginx HTTP’
To check the status of your firewall run the following command
sudo ufw status
Test the Installation
Open your favorite browser i.e Chrome, Forefox or Safari and Enter your server IP address in the browser tab.
http://your_ip
A default Nginx page will be shown in your browser as display below

Congratulations you have successfully installed Nginx server in ubuntu machine.
Manage NGINX server
To stop the nginx server run the following commands
sudo service nginx stop
To start the nginx server run the following command
sudo service nginx start
To restart the nginx server run the following command
sudo service nginx restart
To reload nginx server run the following command
sudo service nginx reload
To upgrade the nginx server run the following command
sudo service nginx upgrade
To check the status of nginx server run the following command
sudo service nginx status
3 Comments
I have been reading out a few of your articles and i must say clever stuff. I will definitely bookmark your blog. Eustacia Peyter Solberg
I was able to find good advice from your blog posts. Rafa Kris Skell
Howdy! This article could not be written any better! Looking through this post reminds me of my previous roommate! He always kept talking about this. I am going to forward this information to him. Fairly certain he will have a good read. Thanks for sharing! Alisa Gerek Soracco