How to Configure Virtual Host in NGINX Web Server

Step 1: Prerequisite

Step 2: Add Domains in nginx Configuration File

To add multiple domains in nginx web server edit /usr/share/nginx/ file and create virtual hosts.

# vi /etc/nginx/conf.d/virtual.conf
# add at the last line

server {
    listen       80;

    location / {
        root   /usr/share/nginx/;
        index  index.html index.htm;

Step 3: Restart nginx server

# mkdir /usr/share/nginx/
# /etc/rc.d/init.d/nginx restart

Stopping nginx: [ OK ]
Starting nginx: [ OK ]

Step 3: Create a Web page

# vi /usr/share/nginx/

<div style="width: 100%; font-weight: bold; text-align: center;">
Nginx Test Page