Knowledge Base
MilesWeb / How-Tos

How to install Nginx on Ubuntu 16.04?

Approx. read time : 3 min

Nginx is a Linux web server that can be used as a reverse proxy, load balancer, mail proxy, and HTTP cache. It accelerates the content by utilizing very low resources and thus is known as a competitor to Apache. To install Nginx on Ubuntu 16.04 follow the steps mentioned in the tutorial.

Prerequisite :

To explain this tutorial we are working on Ubuntu 16.04 LTS server and also logged in as root.

#Steps to install Nginx

1) Update Apt-Get

First, we will update and upgrade our packet manager using the following command.

2) Install Nginx

Below command will install Nginx

3) Verify the installation of Nginx

If the Nginx is installed correctly, then an Nginx’s default file will get appear in /var/www/html as index.nginx-debian.html . In case you see the Apache default page then rename it as index.html file. Just like Apache, the port for Nginx is also port 80, which indicates that if you already have set your record A for your server’s hostname, then you can visit the IP and verify if the installation of Nginx is completed. By the following command if you can get the IP of your server, in case if you don’t have :

Now, use this IP command and visit via HTTP (http://xxx.xxx.xxx.xxx).

Now you can see a similar screen as below, to verify the installation of Nginx.

Nginx

How to change ports for Apache?

In case if you already have Apache established to port 80, then you may find the Apache default page when you visit your host IP. So, you can change this port, in order to make a place for Nginx to take over port 80. To change the Apache port, you will have to visit the Apache port configuration file :

Here, change “Listen 80” to any other port number, for example, we can use port 8080 :

Now, to notice the changes, restart Apache,

All the things that Apache has can now be seen using your IP by replacing the x’s.

For example http://xxx.xxx.xxx.xxx:8080.

Also Read :

1) How to Block IPs with Nginx?

2) Steps to Redirect URLs Using Nginx

Sonam Wagh
With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.
Need help? We’re always here for you.
DON'T LOSE YOUR FREE TRIAL
OFFER EXPIRES IN
04
min
59
sec
Who is your preferred cloud partner?
Let us know and we’ll manage it for you
Amazon Cloud
Digital Ocean Cloud
No, thank you