How To Install Nginx on Ubuntu 18.04

step by step installation of Nginx on Ubuntu 18.04
Priyanka Sharma
Priyanka Sharma

Created: 05/19/2020 2:59 PM - Updated: 05/20/2020 6:15 AM

Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and highest-traffic sites on the internet. It is more resource-friendly than Apache in most cases and can be used as a web server or reverse proxy.

Note-    Before you begin to follow the steps, you should have a regular, non-root user with sudo privileges configured on your server. 

 Step 1 - Installing nginx

 Nginx is available in Ubuntu’s default repositories, it is possible to install it from these repositories using the apt packaging system.

  sudo apt update

  sudo apt install nginx


Step 2 - Adjusting Firewall

Before testing Nginx, the firewall software needs to be adjusted to allow access to the service. Nginx registers itself as a service with ufw upon installation, making it straightforward to allow Nginx access.

List the application configurations that ufw knows how to work with by typing:

  sudo ufw app list

You should get a listing of the application profiles:

  Output-

   Available applications


   Nginx Full


    Nginx HTTP


    Nginx HTTPS


    OpenSSH


 To   allow traffic on port 80.

  sudo ufw allow 'Nginx HTTP'

You can verify the change by typing:

  sudo ufw status

You should see HTTP traffic allowed in the displayed output:

  Output

 Status: active


  To              Action      From


  --                ------        ----


  OpenSSH     ALLOW         Anywhere                  

  Nginx HTTP    ALLOW     Anywhere                 

  OpenSSH (v6)    ALLOW    Anywhere (v6)            

  Nginx HTTP (v6)   ALLOW       Anywhere (v6)


Step 3 - Checking your Web Server

At the end of the installation process, Ubuntu 18.04 starts Nginx. The web server should already be up and running.

We can check with the systemd init system to make sure the service is running by typing:

  systemctl status nginx

.

Output

? nginx.service - A high performance web server and a reverse proxy server


     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)


     Active: active (running) since Fri 2018-04-20 16:08:19 UTC; 3 days ago


       Docs: man:nginx(8)


 Main PID: 2369 (nginx)


      Tasks: 2 (limit: 1153)


     CGroup: /system.slice/nginx.service


           ??2369 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;           ??2380 nginx: worker process

As you can see above, the service appears to have started successfully.

You can access the default Nginx landing page to confirm that the software is running properly by navigating to your server’s IP address.

 Enter your server’s IP address it into your browser’s address bar:

  http://your_server_ip


You should see the default Nginx landing page:




Was this article helpful?

0 Out of 0 Marked As Helpfull

Have more questions? Please Contact Us