Did You Know?

How Can We Help?

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started

How to install NGINX in Ubuntu 18.04 LTS

Table of Content

What is NGINX?

NGINX has powerful load balancing, reverse proxy and cache features, an open-source web server. It was first designed to solve problems of scaling and competition with existing Web servers. Its asynchronous event-based architecture has made it one of the most famous web servers available and the most efficient.

Before You Begin

1. Configure your Cloud server in your Server Guides to get started and secure.

2. You can configure this using our DNS Manager Guide if you want a custom domain name for your site.

Do not forget to update the public IP and fully qualified domain name of your Site, as explained in the Getting Started Guide section of the Update Hosts of your System File.

Install NGINX

Currently, it is best to use version in the repositories of Ubuntu to install NGINX on Ubuntu 18.04 LTS:

[command]sudo apt update
sudo apt install nginx[/command]

Add a Basic Site

1. Build a new website directory. Substitute abc.com for the domain name of your site.

[command]sudo mkdir /var/www/abc.com[/command]

In your /var/www/abc.com directory, you can add your website files. Create an index file using a simple example of "Hello World." Create a new file, /var/www/abc.com/index.html.  with your preferred text editor. Substitute abc.com  with the domain name or the public IP address of your cloud server.

[filecode file="/var/www/abc.com/index.html"]
Microhost Cloud

Configure NGINX

The configuration files NGINX-specific to the site are kept available under /etc/nginx/sites-available  , symlinked to /etc/nginx/sites-enabled/. Generally, for every domain or subdome you host, you want to create a separate original file in the directory available for the sites, and then you set up a symlink to the directory with the sites-enabled.

1. Deactivate the default setup file by removing the /etc/nginx/sites-enabled/ symlink:

[command]sudo unlink /etc/nginx/sites-enabled/default[/command]

2. In your chosen text editor, create a configuration file for your site. Replace abc.com  with your site domain name or IP address in the server_name  directive:

[filecode file="/etc/nginx/sites-available/abc.com"]
server {
listen 80;
listen [::]:80;
server_name abc.com;

root /var/www/abc.com;
index index.html;

location / {
    try_files $uri $uri/ =404;


3. To allow your configuration, establish an additional symlink to the /etc/nginx/sites-enabled/  directory:

[command]sudo ln -s /etc/nginx/sites-available/abc.com /etc/nginx/sites-enabled/[/command]


1. Test your configuration for errors:

[command]sudo nginx -t[/command]

2. Retrieve the settings:

[command]sudo nginx -s reload[/command]

3. Browse the domain name or IP address on your cloud server in your browser. You ought to see your simple page shown.


Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started
Table of Contents