Running website through Nginx Webserver

Running website through Nginx Webserver

What is Web server

A Web server is a program which server HTTP request from server to client. It works on client server model, when client request a URL then it goes to the Web server and Web server is responsible for providing expected response. There are lots of Web Servers are – but most famous Web servers are Nginx, Apache. In this blog we are using Nginx to server a static page to the browser.

In previous blog we already seen that how we install nginx and verify that if nginx is running properly. Now we are going to start next step.

1. We need one html file index.html with following content and place it location mention as root in nginx conf file : In my case it is at /opt/test/html.

###############

Testing Webserver

Hello this is testing static page from nginx web server

 

###############
Screenshot :

2. Now create one Nginx configuration file under /etc/nginx/conf.d/

touch test.conf
Open Configuration file and paste below script

vim test.conf :
server {
listen 80;
server_name test.dominosindia.in;
charset utf-8;
root /opt;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}

Screenshot :

After creating both files you need to restart nginx with command /etc.init.d/nginx restart

 

Note :-

If you are making any change in nginx configuration then you need to reload or restart nginx.

Leave a Reply

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