Setting up Nginx server on Windows 10

Recently, I got my wife an Asus ROG 15-Inch Gaming laptop as a development machine (so that I can have a machine to use when I feel like gaming). Since the Nginx server is one of my favorite servers for building web applications, it is something that I will always setup first when I get a new development machine.

I will set up my Nginx server to listen on port 80 and serve as a reverse proxy to web applications listening on other port numbers. And since the ROG GL552VW-DH74 15-Inch Gaming laptop came with Windows 10, this post documents the steps that I went through to set up Nginx server on Windows 10.

Downloading a copy of Nginx

The first thing that I did was to download a copy of Nginx for Windows. To do so, I go to the Nginx download page and click on the link labelled as nginx/WindowsXXX located under the section named Stable version. As of this writing, I downloaded nginx/Windows-1.10.2 and unzipped the contents to D:\servers. This will create the folder D:\servers\nginx-1.10.2 which contains everything that is needed for me to run Nginx on Windows 10.

Starting Nginx for the first time

To test whether the copy of Nginx that I had downloaded is working, I opened up command prompt and typed the following commands:

cd /d D:\servers\nginx-1.10.2

Running the above commands triggered the following dialog box:

Windows Security Alert after starting Nginx for the first time

I clicked on the Allow Access button to get my Windows 10 firewall to associate port 80 to my Nginx server. I then opened up my browser and type localhost in the location bar and saw the following message:

Nginx welcome page on Chrome Windows 10

Stopping Nginx server

Once I had ensured that my Nginx server is able to run in my Windows 10 machine, I opened up another command prompt and typed the following commands to stop the Nginx server:

cd /d D:\servers\nginx-1.10.2
nginx -s stop

Setting up Nginx server to start automatically when Windows 10 starts

Having to open up the command prompt to start Nginx every time I do my development work is cumbersome. Hence, I proceeded to set up my Nginx server to start automatically whenever my Windows 10 starts. Since the Nginx binary is not a windows service executable, I set it up to start automatically via the common Startup folder.

To do so, I created a shortcut of the nginx.exe binary and copied it to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp. This will ensure that my Nginx server starts automatically whenever I log into my Windows 10 machine.

Restarting Nginx server

To restart my Nginx server on my Windows 10, I open up my Windows prompt and type the following commands:

cd /d D:\servers\nginx-1.10.2
nginx -s stop

For convenience, I created a .bat file that contains the above commands on the desktop so that I can quickly restart my Nginx server when I need to do so in the future.


About Clivant

Clivant a.k.a Chai Heng enjoys composing software and building systems to serve people. He owns and hopes that whatever he had written and built so far had benefited people. All views expressed belongs to him and are not representative of the company that he works/worked for.

Advertisements Homepage 300x250 Domain names for just 88 cents!

Find a domain starting at $0.88

powered by Namecheap