How to Install and Run the Nginx Server on Windows

Nginx is a web server that is very popular with Linux and BSD systems. It can also be installed on Windows as long as you can live with performance limitations that have not been mitigated so far. You can still host a web server or a customer/employee portal from the comfort of your Windows laptop. To install and run Nginx successfully on Windows, follow the steps below.

Tip: if all you need is a local web server to test your applications, here are the ways to set up a local web server in Windows.

Installing Nginx in Windows

To get started, we will need to install Nginx on your Windows laptop or PC. There are no conventional Nginx installers with this operating system. You will need to download one of its online versions and save it to a C: drive location of your PC.

  1. Select the version you want and download its zip file to your PC. Nginx recommends using the “mainline version” as it comes with the latest features. If you don’t need those features, the most recent stable version will work too.
Downloading the mainline version of Nginx from its official website.
  1. Once downloaded, extract the new folder by right-clicking on it. You may also use popular compression software such as 7-zip or WinRAR.
Right-click to extract all files for the downloaded Nginx installer software.
  1. Move the entire folder that came with the built-in download copy into the C: drive. In this example, we moved it to “Program Files” but it can be saved at any location on your PC including D drive.
Moving extracted Nginx folder to the Program Files.
  1. Select and double-click the “Nginx.exe” file. It has now been activated for further use. We will run Nginx from this location as a default web service program.
Double-click Nginx application inside the Program Files folder.
  1. If you have enabled Windows SmartScreen filter, it may prevent the Nginx installer from running. Click “More info” to bypass the limitation.
Click "More info" on the SmartScreen blocking Nginx application window.
  1. Click the “Run anyway” text to run the nginx.exe file.
SmartScreen blocks Nginx application which you can run anyway.
  1. You may further run into a Windows Defender firewall block screen while running the Nginx server, which has to be allowed by you. Once done, you can readily use Nginx on your Windows device.
Windows Defender firewall has blocked Nginx application. Click Allow access to run it.

Do you know: wondering what is the difference between Nginx and Apache? We have the answers here.

How to Start Nginx on Windows

There are multiple ways to run Nginx on your Windows PC depending on your end use requirements. You can use these methods simultaneously. For example, you can launch the Nginx server using its application file or from PowerShell.

1. Using Nginx Application File

Nginx has a built-in application file that you can double-click as described in above section. You will need to bypass any restrictions due to SmartScreen or Windows Defender.

  1. Once done, go to your default browser and type localhost. Microsoft Edge is the browser used in the below example.
  2. If you see a screen saying the Nginx web server is successfully installed and working, it means there were no problems with your Nginx installation in Windows.
Edge browser in Windows showing Nginx default script after entering "localhost" on the address bar.
  1. To stop Nginx, you can end it from the Task Manager window. If you can’t terminate it directly from the Processes, right click to select “Go to details.”
Right click to select "Go to Details" for the Nginx process in Task Manager.
  1. Identify all instances of Nginx.exe and right click to end each task.
Right click to select "End task" tp terminate Nginx process inside Task Manager inside the Details window.
  1. Ignore any warning such as “do you want to end Nginx.exe.” Click “End process” to continue with the termination.
Click "End process" to terminate Nginx.exe from the Task Manager.
  1. When you type localhost, you will see a “can’t reach this page” screen on your browser web page.
Nginx localhost displaying "Can't reach this page" error on browser.

2. Using PowerShell

The best part of Nginx is that it can run as an automated script from PowerShell and also the Command Prompt. We will demonstrate that for PowerShell below.

  1. Launch PowerShell in Administrator mode.
Running PowerShell as administrator.
  1. Go back to the folder where you saved the Nginx application, and right-click to go to its Properties. Here you can copy the exact folder path. In this example, it is “C:\nginx-1.25.1\nginx-1.25.1”
Location path of Nginx application file in installed Nginx folder.
  1. Change the PowerShell directory to point to the above path.
cd Path of Nginx installer
Redirecting PowerShell to Nginx application folder path.
  1. To initiate the Nginx server, type the following command.
Start Nginx in PowerShell in Administrator mode.
  1. You can view Nginx.exe process instances in Task Manager nested under Windows PowerShell.
Nginx running as background processes in PowerShell window as seen in Task Manager.
  1. On Windows, Nginx can be run as a standard console app. For managing it, the following simple commands are frequently used:
nginx -s stop Rapid shutdown
nginx -s quit Graceful shutdown
nginx -s reload Changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
nginx -s reopen Reopening log files
  1. If you encounter any error such as “the command nginx was not found, but does exist in the current location,” PowerShell will prompt you to use a different command. In the following example, we have replaced all instances of nginx with /.nginx, using them to reload and quit the program.
List of Nginx commands in PowerShell window.

3. Using IIS Manager

You can also use Internet Information Services (IIS) to run Nginx which is a Microsoft web server that serves requested HTML pages or files. In the past, it was compulsory but it’s no longer the case.

  1. You can enable it in “Turn Windows Features On or Off” in the Control Panel. Check the required fields for “Web Management Tools” and “IIS Management Console.”
Turn IIS Management Console On under the Internet Information Services.
  1. It will take a while for IIS to be enabled on your computer as the changes are applied.
Applying changes to turn on Windows features in the window.
  1. You will see a success status that “Windows completed the requested changes.”
Windows completed the requested changes to turn on the required features with IIS Console.
  1. You can open IIS Manager directly from the Start menu. Always open it in Administrator mode.
Open IIS Manager app from Start menu in Administrator mode.
  1. Here, you will be able to access the default website, which is usually located at “inetpub wwwroot.” This is also known as the web application root. You can look for it in File Explorer through a simple search.
  2. When you double-click on the “default web site” option in IIS Manager, it should lead to this new folder. Alternatively, you can right-click the menu and select “Explore” for the same result.
Root folder of PC as identified using IIS Manager.
  1. Once your IIS Console is enabled, you can view its webpage by typing localhost on your default browser.
Local Host in Nginx pointing to IIS website.

How to Configure Nginx For Windows

To run Nginx in Windows, all desired changes are affected from various strings modified in the “index.html” and “nginx.conf” files in the installation folder. These strings are usually edited using the Notepad text editor, but you can use any other editor such as Atom, Notepad++ or Visual Studio Code. In this case, we will edit the configuration file using Notepad++.

  1. Go to the folder where you saved your Nginx application. Click the “html” subfolder.
HTML subfolder in Nginx folder.
  1. Right click to select “Edit with Notepad++” for the index.html file.
Right click to edit Index HTML file in Nginx folder using Notepad++.
  1. You can edit the index.html file in the root folder in a new or separate tab. Change the text to what you want the web server to display on the screen.
  2. Don’t forget to click the “Save” button on top once you’re done.
  3. Exit the Nginx.exe program using “End Task” as shown in above section and restart it.
Editing HTML file of Nginx with text changes and saving the file.
  1. Type localhost in a browser window. The Nginx web server will highlight the edits you made.
Edited text viewed as localhost on the default browser.
  1. After this, click “Conf” and right click to select “nginx.conf” followed by “Edit with Notepad++.”
Right click to edit Nginx conf file with Notepad++.
  1. Find the location of the root and change it from the default html to any other physical path.
Changing Conf File Root path using Notepad++.

To know more about Nginx commands, including the documentation, visit this link.

Example Application of Nginx in Windows

Nginx supports multiple applications in Windows, such as web server, load balancer, reverse proxy, or even host your own Youtube site. The Nginx resources site has a full list of web server applications which you can use to run various applications on Windows PC.

For example, you can use Nginx in Windows to link to a webpage such as a customer login page. Once you make the configuration changes in the “nginx.conf” file, your end users will be able to access the login page on their end.

  1. Go back to the “nginx.conf” file shared in the previous section. Instead of “somename,” you need a domain name for the server to access.
Adding a domain name in Conf file of Nginx.
  1. Go to “location” and modify the text using an “api,” followed by a proxy server added with an “http” ping. This should point to any login page you want this page to direct to. Here we have a “proxy_pass” field which has a “127.0.0.1′ URL local to your Windows machine.
  2. Save the file and run the “Nginx.exe” program in Admin mode.
Replace Proxy path with a login page in Nginx Conf file.
  1. As shown here, 127.0.0.1 is what Nginx.exe points to, and this is the path you can modify in above Conf file to point to an external customer portal or web server.
127.0.0.1 page visible in browser with Nginx.

Frequently Asked Questions

How to solve Nginx’s “The system cannot find the path specified” error in Windows?

Sometimes while running Nginx in Windows Command Prompt/PowerShell, you may run into a “System cannot find the path specificed” error. To avoid it, go to the folder where you saved the Nginx.exe application, and right click on it to view its properties, which will give the exact path it is located. There could be a few other reasons behind this, and we have a detailed guide to fix the issue.

What are the disadvantages of Nginx in Windows?

Even though it supports Windows, Nginx is not the best choice for the operating system. Its biggest disadvantage is that it’s incapable of multitasking. For instance, you can execute only one process at a time. If you are running a web server, your Windows machine will be occupied with that one task. This poses challenges in scalability, and one Windows device isn’t sufficient to work with Nginx.

How popular is Nginx?

Nginx is one of the leading web server companies today. Also, it is faster, can handle more concurrent issues and is reliable. To summarize, if you have a simple website you want to connect to Nginx, you can do it right now without any problems. Read on to check out the comparison of Nginx to OpenLiteSpeed.

All images and screenshots by Sayak Boral.

Sayak Boral
Sayak Boral

Sayak Boral is a technology writer with over eleven years of experience working in different industries including semiconductors, IoT, enterprise IT, telecommunications OSS/BSS, and network security. He has been writing for MakeTechEasier on a wide range of technical topics including Windows, Android, Internet, Hardware Guides, Browsers, Software Tools, and Product Reviews.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Leave a Reply

Your email address will not be published. Required fields are marked *