Installing Nginx on Ubuntu 18.04


Reading Time: 3 mins.
Nginx, the most widely used web servers in recent years, is popularly known for its simple configuration, stability and high performance. Unlike the other web servers, it can also function as a proxy server and cache server. This article will help you find the how-to of installing the Magento platform using Nginx web server on Ubuntu 18.04.
To know more about the Nginx’ functionality, features, advantages and benchmarking, you can read our article on Know the Differences: Which Stands Out, Apache or Nginx for Magento?

Pre-conditions

  • It is to be noted that the given instructions are applied to installing Nginx server on Ubuntu 18.04.
  • Presuming that you are logged in as a non-root user (in which sudo privileges is necessary).

Step 1: Updating the default system packages

Before delving into the installation process of the Nginx, you need to make sure whether the list of available packages is updated.
To update the Ubuntu package manager, use the below-shown command.

sudo apt-get update

Now your system is ready to install Nginx.

Step 2: Installing Nginx

Soon after updating the package list, the installation step is all about giving a command through apt-package manager. 

sudo apt-get install nginx

By this time, Nginx has been successfully installed in your system. 

Step 3: Configuring the Firewall

In Linux distributions, you no need to install ufw, since it contains all the necessary ufw by default. 
Most importantly, you need to enable the firewall  (as it is in the disable mode by default) using the command:

sudo ufw enable

To disable the firewall, use the command:

sudo ufw disable

To view the default ufw rules, use the command:

sudo ufw app list

You will be presented with the predefined rules in the list as follows:

Output
Available rules:
Nginx Full
Nginx HTTP
Nginx HTTPS
OpenSSH

Further, you need to allow the configured profiles such as Nginx Full and Nginx HTTP using the commands:

sudo ufw allow ‘Nginx HTTP’
sudo ufw allow ‘Nginx Full’

Further, by using the custom firewall rules, you can make the system highly-securable.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top