Installing NGINX in Ubuntu 18.04 LTS

Installing NGINX in Ubuntu 18.04 LTS

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:

sudo apt update
sudo apt install nginx

Add a Basic Site

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

sudo mkdir /var/www/abc.com

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.

/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:

sudo unlink /etc/nginx/sites-enabled/default

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:

/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:

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

Test NGINX

1. Test your configuration for errors:

sudo nginx -t

2. Retrieve the settings:

sudo nginx -s reload

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

Thankyou..

    • Related Articles

    • How to Configure NGINX

      NGINX is a web server designed for high-traffic cases that is lightweight and highly efficient. The ability to easily support static content such as HTML and media files is one of the most significant features of NGINX. NGINX uses a predictable ...
    • NGINX: Installation and Basic Setup

      Before You Begin You need root access of the server or a sudo  privileged user account. Set the hostname of your cloud server. Update your server. Install NGINX Stable Versus Mainline The first decision on your installation is whether you want NGINX ...
    • Use NGINX as a Reverse Proxy

      What is a Reverse Proxy? A reverse proxy is a server between internal and external clients which transmits clients requests to a different server. Although other standard applications, such as Node.js, can support themselves, NGINX has a range of ...
    • Installation of LAMP Stack on Ubuntu 16

      LAMP, which operates Linux as the operating system, is an open-source web-developing platform using Apache as the web-based server and PHP as an object-oriented scripting language. (Instead of PHP, Perl or Python are sometimes used.) Prerequisites ...
    • Nginx Installation in CentOS 7

      Step 1: Add Nginx repository . Command :  # yum install epel-release Step 2:  Install Nginx using following command . Command: # yum install nginx Step 3: Start the service of Nginx . Command :  # systemctl start nginx Step 4: Check status of Ngnix . ...