Learn Nginx installation on windows and Linux

Nginx is a popular open-source web server just like an apache server. This will be used in the most popular websites to generate static HTML content.

Nginx Supports the following features

  • SSL support
  • Load Balancing
  • HTTP Caching
  • Static files can be hosted
  • HTTP authentication
  • Rewrite support for redirection
  • Integrated Proxy and reverse proxy

In this blog, We will go through Nginx installation on Windows, Linux, and Ubuntu

Install on windows

First please download the latest from nginx-1.15.1.zip🔗, and extract it, place in a C folder like c:\nginx-1.15.1 You can set environment variables if required to run Nginx command from anywhere To check Nginx installation using Nginx -v command

C:\\nginx-1.15.1>nginx -v
nginx version: nginx/1.15.1

Nginx Command options



-? or -h

display documentation of help command


Display Version of Nginx server


Test and display configuration information


Test and dump configuration information

-s Signal

Sent a signal to Nginx process, signals are quit, stop, reopen, reload

-c CustomFileName

The default configuration file is conf/Nginx.conf. you can add a customized custom configuration file to read

Start/Stop server in windows

nginx -s stop - stopping the server nginx -s quit - graceful stopping the server nginx -s reload - reloading the configuration without restarting the server.

List out Master and child process

c:\nginx-1.15.1>tasklist /fi "imagename eq nginx.exe"
Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
nginx.exe                    14288 Console                    1      6,008 K
nginx.exe                     5032 Console                    1      6,020 K

Log Location in windows are C:\nginx-1.15.1\logs.

**access.log** - each request logged to the server has an entry in access.log
**error.log** - if any error comes, you can check the error logs

Install a web server on a Linux operation system

It is a very simple process install using prebuilt packages on Linux os, using yum command, first install epel package and update it using below command.

sudo yum install epel-release
sudo yum update

Using Debian-based packages :

sudo apt-get install Nginx
sudo apt-get update

How to get Error logs Nginx logs are placed under /var/log/Nginx

tail -f /var/log/nginx/error.log

Display Nginx version information

C:\nginx-1.15.1>nginx -v
nginx version: nginx/1.15.1

How to change the default port is 80

To change this to a different port, please modify the Nginx configuration

vi /etc/nginx/conf.d/default.conf
listen       81;
server_name  localhost;
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 81 -j ACCEPT

And add this port to the iptables configuration to allow this port

 vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 81 -j ACCEPT

Now restart Nginx and ip tables to reload these changes.

sudo service iptables restart;
sudo service nginx restart

The web server started with listening at 81 port.

setup configure nginx windows and linux

Now you can access the webserver http://localhost:81