Nginx is free and open-source software and is used as a web server, and it can also be used as a reverse proxy server. Apart from that, Nginx is also used as a load balancer, mail proxy, and others.
By the way, in this article, I will explain “How to install Nginx server on ubuntu 20.04 system.“
- Ubuntu 20.04 Local or server system
- Root or Sudo privileges
Steps to Install Nginx Server on Ubuntu 20.04
As mentioned above, you have to require the pre-requisites to install the Nginx web server on Ubuntu. The installation procedure is straightforward, and you have to follow the steps one by one to configure the server.
Step – 1. Update System
Execute the following command to update the Ubuntu system before installing the Nginx web server.
sudo apt update
Step – 2. Install Nginx server
After updating the system, run the following command to install the Nginx server on Ubuntu 20.04 machine.
sudo apt install nginx
[email protected]:~# apt install nginx Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 nginx-common nginx-core Suggested packages: libgd-tools fcgiwrap nginx-doc ssl-cert The following NEW packages will be installed: libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 nginx nginx-common nginx-core 0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded. Need to get 1214 kB of archives. After this operation, 4275 kB of additional disk space will be used. Do you want to continue? [Y/n]
It will prompt you to “Do you want to continue?” Type “Y” and hit the ENTER key. The installing process will take a little time (Depending on the network).
Step – 3. Verify the Nginx installation
Now, after installing the Nginx web server on the Ubuntu system, you have to verify whether is that successfully installed or not? There are two methods. First, run the following command:
sudo nginx -v
[email protected]:~# nginx -v nginx version: nginx/1.18.0 (Ubuntu) [email protected]:~#
The second method is to open your web browser and type your public IP address or localhost (
http://127.0.1.1 ) for the local machine.
Step – 4. Allow access protocol or Uncomplicated Firewall for Nginx
For accessing the Nginx web server, you need to set the ufw (Uncomplicated Firewall) rules. However, on a cloud server, you can specifically set the firewall rules via instance security settings, but you can run the following commands if you haven’t set them yet.
List ufw app list:
sudo ufw app list
sudo ufw allow 'nginx http'
sudo ufw allow 'nginx https'
sudo ufw allow 'nginx full'
Note:- To grant access to the Nginx server, you can enable one of the firewall protocols or both of them.
Reload Firewall system:
After setting up the firewall rule, for changes, you have run the following command:
sudo ufw reload
How To Manage Nginx Server on Ubuntu
I hope you understand the complete procedure of installing the Nginx server on Ubuntu. You should also know the basic commands to manage an Nginx server, like stopping, restart, start and reload.
Check Nginx Web Server Status:
sudo systemctl status nginx
sudo service nginx status
Start Nginx Web Server:
sudo systemctl start nginx
sudo service nginx start
Restart Nginx Web Server:
sudo systemctl restart nginx
sudo service nginx restart
Reload Nginx Web Server:
sudo systemctl reload nginx
sudo service nginx reload
Stop Nginx Web Server:
sudo systemctl stop nginx
sudo service nginx stop
FAQs About Nginx Server
What is the Nginx server?
Nginx is free and open-source software, and it can be used as a reverse proxy server, load balancer, caching, or mail proxy. Nginx is designed for fast performance and stability.
How do I start the Nginx server?
If the system hasn’t installed the Nginx server yet, install it and run the command
sudo systemctl start nginx.
What is the Nginx proxy server?
An Nginx reverse proxy is an intermediary proxy service that takes a client request and passes it on to one or more servers, and subsequently delivers the server’s response back to the client.
Can Apache and Nginx run on the same server?
Apache and Nginx both can run simultaneously. But as per their behavior, they both listen to the same port, so the default config doesn’t allow them to start at the same time. And their port number will be different.
So, guys, that was the tutorial on installing the Nginx web server on Ubuntu 20.04 system. If you face any issues while installing the Nginx, please let me know in the comment box. I will try to help. If you think this article cloud be helpful for any other person, don’t forget to share. Thanks.
Other Related Post:
- Move Files and Directories using Linux mv Command
- How To Install phpMyAdmin On Ubuntu
- How To Install Nginx Server On Ubuntu 20.04