How to Install NGINX on Ubuntu 18 04

How to Install NGINX on Ubuntu 18 04

In this article, we will learn How to download and Install NGINX on Ubuntu 18.04.

Following are the steps to download and Install NGINX on Ubuntu 18.04 Google Cloud Compute Engine VM Instance.

Step 1 - Create a new Ubuntu 18.04 VM

First, create a new VM instance for Ubuntu 18.04. We are using the following configuration for our demo VM machine.

Open SSH in the browser for the new VM Instance.

Step 2 - Install NGINX

Ubuntu 18.04 VM Instance running and we have access for SSH. Next, we will install NGINX. NGINX is available in Ubuntu's default repositories. We will install NGINX from the default repositories. Execute the following command to install NGINX.

sudo apt update

sudo apt install nginx

Above two commands will install NGINX on Ubuntu. Now, we can check the status for NGINX. Execute the below command to check NGINX Status

systemctl status nginx


NGINX status is active and it is running. Let's check our server IP in the browser.
Visit: http://<Your-Server-IP>

Note: You can also use your domain if it is pointing to the server IP.

NGINX Commands

Following are the important commands for NGINX.

  • Start NGINX Web Server: sudo systemctl start nginx
  • Stop NGINX Web Server: sudo systemctl stop nginx
  • Restart NGNIX Web Server (stop and then start): sudo systemctl restart nginx
  • Apply new NGINX Web Server configurations: sudo systemctl reload nginx
  • By default NGINX start automatically. You can disable it with command: sudo systemctl disable nginx
  • Enable NGINX start up at boot: sudo systemctl enable nginx
  • Finally, NGINX Status: systemctl status nginx

Important NGINX files and directories

NGINX Content: You can find the default NGINX HTML page at /var/www/html.
NGINX Server Configuration: All NGINX Configurations files are available at /etc/nginx

  • conf.d  
  • fastcgi.conf  
  • fastcgi_params  
  • koi-utf  
  • koi-win  
  • mime.types  
  • modules-available  
  • modules-enabled  
  • nginx.conf : The main NGINX configuration file. We can modify it later as per our requirement.
  • proxy_params  
  • scgi_params  
  • sites-available: We can find all the domain-specific configuration file in this directory. NGINX ignore the domain configuration if it not available in the sites-enabled directory.
  • sites-enabled: It contains links to configuration file available in sites-available directory files. We can find links for only active sites. In other words, if links for any particular config file is available it means that particular site is enabled and active.
  • snippets  
  • uwsgi_params  
  • win-utf

NGINX Server Logs

/var/log/nginx/access.log: Every request to our web server is recorded in this log file.
/var/log/nginx/error.log: All the NGINX errors are recorded in this log file.

In the Next article, we will learn How to download and Install PHP, MySQL, and PHPMyAdmin on our Ubuntu 18.04 server.

Leave A Comment

Please login to post your valuable comments.

Join the newsletter

Get the latest vLemonn news first