How to Install Nginx on Windows

Nginx is a free and open-source web server that can also be used as a reverse proxy server, load balancer, and HTTP cache. Nginx comes with a pre-compiled package for Windows; therefore we would not need a compiler to use the Nginx on Windows. In this guide, we will show you step-by-step on how to install Nginx on Windows.

First, download the Nginx latest stable version or mainline version. To understand the difference between the Stable and Mainline version, Let’s do some discussion.

The Mainline version has some major bugs, whereas Stable has no bugs. In other words, the Stable version is derived from the mainline version by fixing some major bugs, but it lags some extra features.

To download the Nginx latest version for Windows, go here – https://nginx.org/en/download.html

Install Nginx on Windows

Once you’ve downloaded the Nginx, you get a zip file; first, extract the zip file. You can extract the zip file anywhere you want, but I recommend you to extract in the root (C drive) directory.

Now open the Nginx folder you extracted recently, and you get a nginx.exe, double click the nginx.exe to run the Nginx server on Windows. To make sure that Nginx is running properly, open the web browser and type the localhost or 127.0.1.1 in the address bar. You should see the Nginx welcome page.

nginx for windows

Some important files:

  • Nginx configuration file: Nginx/conf/nginx.conf
  • Default web root directory: Nginx/html/
  • Log files: Nginx/log/
  • Default listen-address: localhost or 127.0.1.1

Important command for Nginx:

You can use these command directly in the Command prompt to control the Nginx web server on Windows.

  • To start the Nginx server – nginx -s start
  • To stop the Nginx server – nginx -s stop
  • Restart the Nginx server – nginx -s reload
  • Test the server configuration file – nginx -t
  • For help options – nginx -h
  • To check the software version – nginx -v

To use these commands, you must update the Nginx path in the environment variable. If you don’t know how to do this, then Here’s how to do this.

Update Nginx path variable in Windows

  1. First of all, go to the location where you install the Nginx.
  2. Hold down the Shift key and then right-click the Nginx folder, then copy the full path.
  3. Next, open the control panel and navigate to the following: System and Security > System > Advanced system settings
  4. Under the Advanced system settings, you get the system properties window.
  5. Navigate to the Advanced tab, then under the startup and recovery, click the Environment Variables…
  6. This will open a new Environment Variables window. Under the user variables section, select the Path variable and then click the Edit button.
how to install nginx on windows
  1. Then, click the New, and then enter the full path of the Nginx installed folder you copied.
how to install nginx on windows
  1. Click the OK button to finish.

Now you can use all the Nginx command in the command prompt without navigating the Nginx installation path. I hope this guide helps you to install the Nginx web server on Windows properly.

Leave your reply here

Scroll to Top