That’s it. Your installation is complete and your webserver is up and running.

Nginx server test

Now you can enter your server IP in the browser (http://x.x.x.x/) to check if your Nginx webserver is serving page or not. If you are getting a connection timed out, you may want to check firewall settings on your server to allow port 80.

You will be served with test page like below :

nginx test page on YUM based systems like Red Hat

nginx test page on APT based systems like Ubuntu

This confirms that your Nginx web server installation is successful and it’s ready for customization.

nginx configurations

The default server root directory is /usr/share/nginx/html. Files that are placed in there will be served on your web server. You can place your HTML files here to serve a static website! The test page you seen above is file index.html under /usr/share/nginx/html.This default directory can be changed under Nginx configuration file /etc/nginx/conf.d/default.conf.

nginx global configuration file is/etc/nginx/nginx.conf. In this conf file, you can set the user to run Nginx, its number of processes to fork, etc.

Directory listing in nginx

If you place a few files or directories in root directory then you will not see a listing of them in your browser as we saw in Apache configuration. To enable this you need to add autoindex on; in config file after root directive. Look at my config below :

In the above config, I defined /tmp as root and turned on autoindex (highlighted lines). Restart Nginx services after saving the above changes. Now if I check my webpage (http://x.x.x.x/) it will list all files/directories under /tmp

Directory listing in nginx

You can see in above screenshot, /tmp directory listing is presented by Nginx. If you don’t put autoindex on then it will serve you 404 forbidden error!