Install And Configure NGINX

In order for visitors to see anything on your website, the first thing you want to do is to prepare a basic Ubuntu server which will give you a “foundation” for your configuration and files. To deliver the pages to your visitors, this guide will show you how to install the free open source NGINX HTTP server and then get your first message up for the world to see in less than 15 minutes.

Login to your server

First we’ll make sure the source list is up to date and then install NGINX:
sudo apt-get update && sudo apt-get install nginx

Welcome To NGINX

Now open a web browser and type the IP address that was provided to you. It should load with the default welcome message.

Let’s configure NGINX so that it will display our own message.

Note: example.com can be replaced with your domain name or anything you want

First, we need to create a folder to store it:
sudo mkdir -p /var/www/example.com/public_html

Now let’s create our own test message for the world to see:
sudo nano /var/www/example.com/public_html/index.html

Type any message you want. For this example, we’ll type in:
hello world

Save the file by pressing CTRL X on your keyboard

Let’s make a copy of the default file:
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com

Open the new file for editing:
sudo nano /etc/nginx/sites-available/example.com

Modify the root path to match the folder path we created earlier:
from root /usr/share/nginx/html;
to root /var/www/example.com/public_html;

CTRL X to save your file

Activate the new configuration
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

Remove the default
sudo rm /etc/nginx/sites-enabled/default

Restart NGINX
sudo service nginx restart

Open a browser, type the IP address of your server and you should now see the hello world message.