Setting up nginx server on Windows 10
Recently, I got my wife an Asus ROG GL552VW-DH74 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 nginx
Running the above commands triggered the following dialog box:
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:
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 nginx
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.