Installing Nignx as a Service on Windows

Setting up Nginx on Windows is a straightforward endeavor. Unfortunately the information on how to do it end to end is not exactly in one spot, but actually sprinkled throughout the internet. So here we go, let's put it all together.

Installing Nginx

  1. Download the binary from the Nginx website. This is what the website looks like today and the latest version is 1.15.2. nginx download page

  2. Unzip it to a folder of your preference. You might want to unblock the download first though, by right-clicking and selecting properties. On the properties window there's an unblock checkbox. In this case I am going to unzip the download directly on the root. It will look something like this: nginx unzipped folder

You could now start it up as a console application by running nginx.exe, but that's only useful if you only want it to run when you're logged in. We want it to run whenever the computer starts, so let's install it as a windows service.

Setting Nginx Up as a Windows Service

The guidance here is to use one of the many tools out there that let you install an executable as a windows service. There's no magic here. That all it is. We wrap the executable in a service wrapper and install it using one of the open source tools available to us. I'll show you how to do it using NSSM, but just follow the instructions for the particular wrapper tool you end up using.

Installing nssm

  1. Download the NSSM binary from the NSSM website. Like Nginx, that is also a zip file.
  2. Unzip nssm to any folder but unblock it before you do. Again I'm going to unzip it to the root of the drive and use the folder name that is in the zip file. It will look something like this: nssm unzipped folder

Using NSSM to Install Nginx as a Windows service

The last part is to use NSSM to create a windows service that will run the nginx executable. That's simple enough but it must be done from a command window. So open a command window and run the following command:

 nssm install

This will launch the NSSM "helper" and you can now select the nginx.exe file and give the service a name: nssm application window The defaults will work, except that you should set up a user to run the nginx service and not use the system account because it has unrestricted access to the machine. The Log on tab is where you can change that: nssm log on as screen Feel free to explore the rest of the options in NSSM's help pages.