Can we install nginx in Windows?

Version of nginx for Windows uses the native Win32 API (not the Cygwin emulation layer). Only the select() and poll() (1.15.9) connection processing methods are currently used, so high performance and scalability should not be expected. Due to this and some other known issues version of nginx for Windows is considered to be a beta version. At this time, it provides almost the same functionality as a UNIX version of nginx except for XSLT filter, image filter, GeoIP module, and embedded Perl language.

To install nginx/Windows, download the latest mainline version distribution (1.23.2), since the mainline branch of nginx contains all known fixes. Then unpack the distribution, go to the nginx-1.23.2 directory, and run nginx. Here is an example for the drive C: root directory:

cd c:\
unzip nginx-1.23.2.zip
cd nginx-1.23.2
start nginx

Run the tasklist command-line utility to see nginx processes:

C:\nginx-1.23.2>tasklist /fi "imagename eq nginx.exe"

Image Name           PID Session Name     Session#    Mem Usage
=============== ======== ============== ========== ============
nginx.exe            652 Console                 0      2 780 K
nginx.exe           1332 Console                 0      3 112 K

One of the processes is the master process and another is the worker process. If nginx does not start, look for the reason in the error log file logs\error.log. If the log file has not been created, the reason for this should be reported in the Windows Event Log. If an error page is displayed instead of the expected page, also look for the reason in the logs\error.log file.

nginx/Windows uses the directory where it has been run as the prefix for relative paths in the configuration. In the example above, the prefix is C:\nginx-1.23.2\. Paths in a configuration file must be specified in UNIX-style using forward slashes:

access_log   logs/site.log;
root         C:/web/html;

nginx/Windows runs as a standard console application (not a service), and it can be managed using the following commands:

nginx -s stop fast 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 re-opening log files

Known issues

  • Although several workers can be started, only one of them actually does any work.
  • The UDP proxy functionality is not supported.

Possible future enhancements

  • Running as a service.
  • Using the I/O completion ports as a connection processing method.
  • Using multiple worker threads inside a single worker process.

Nginx is a web server that is very popular with Linux and BSD systems. It can also be installed on Windows 10. However, there are a few performance limitations in Windows that have not been mitigated so far, but the developers will address these problems in a future release. To install and run Nginx successfully on Windows, follow the steps below.

Download the Nginx Server

There are many download versions of Nginx for Windows, and Nginx recommends using the “mainline version.” However, you will not find any issues if you download its most recent stable version for Windows.

Select the version you want and download its zip file to your PC.

Nginx Windows Mainline Version Download

As a first step, you need to extract the new folder. You can use 7-zip, WinRAR or any other popular compression software.

Nginx Windows Extract Zip File

After extracting the file contents in the original folder, you have to move the entire folder that came with the built-in download copy into the “Program Files.” We can either move or cut-paste this extracted folder.

Nginx Windows Program Files

We will run Nginx from this location as a default web service program.

Installing Nginx

To install and run Nginx, select and double-click the Nginx.exe file. It has now been activated for further use. You may run into a Windows Defender block screen while running the Nginx server, which has to be allowed by you.

Nginx Windows Run Program

In the next step, you need to verify whether the installation has been successful. For this, go to your default browser and type localhost. Microsoft Edge is the browser used in the below example. 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.

Nginx Windows Browser Localhost

To stop Nginx, you can end it from the Task Manager window.

Nginx Windows End Task

Running Nginx on Your Windows PC

To run Nginx, you have to use Internet Information Services (IIS), which is a Microsoft web server that serves requested HTML pages or files. 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.”

Nginx Windows Iis Enabled

It will take a while for IIS to be enabled on your computer as the changes are applied.

Nginx Windows Iis Applying Changes

You can open IIS Manager directly from the Start menu. Always open it in Administrator mode.

Nginx Windows Iis Manager Start Menu

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.

Nginx Windows Inetpub Root Folder

It is helpful to change the physical path of this root to a more desirable folder. I created a new “Work” folder in C:\ and changed the physical path to “C:\Work.” 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.

Nginx Windows Iis Manager Root Folder

After this, go to the Nginx folder that you renamed in the Program files. Click “Conf” and select “nginx.conf.” This file can be edited using the Notepad++ text editor, but you can use any other editor such as Atom or Visual Studio Code.

Edit Nginx Conf File With Notepadplusplus

In Notepad++, find the location of the root and change it from the default html.

Nginx Windows Location Root

As shown here, change the root to the edited physical path which we discussed above.

Nginx Windows Location Root Changed

You can edit the index.html file in the root folder in a separate tab. Change the text to what you want the web server to display on the screen.

Nginx Windows Text Changed Index.html

Exit the Nginx.exe program using “End Task.” Open and run the “nginx.exe” file in Admin mode.

Type localhost in a browser window. The Nginx web server will highlight the edits you made.

Nginx Windows Runing Program

Example Application of Nginx in Windows

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.

Go back to the “nginx.conf” file shared in the previous section. Instead of “localhost,” you need a domain name for the server to access. “index.html” is a command used to point to any static html page.

Nginx Windows Put Domain Name

In the next step, 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.

Nginx Windows Proxy Server Login

Save the file and run the “Nginx.exe” program in Admin mode. For this login page to look nice to the end user, you should have previously configured the web server in an IDE program like Eclipse.

Frequently Asked Questions

1. What are the basic commands in operating Nginx for Windows 10?

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

2. What is the role of IIS Webserver in Nginx applications in Windows?

IIS is Microsoft’s native web server which supports HTTP, HTTPS, SMTP, and other protocols, and is not enabled in Windows as default. When Nginx is installed in Windows, it handles the live traffic based on changes made in nginx.conf files. For this, Nginx has to connect internally to an enabled IIS and then cache its response for any future requests.

Nginx’s biggest strength is that it is used at the front end before high load dynamic sites. Imagine tens of thousands of your website users downloading an important video file from IIS at the same time. It can become painfully slow. if you have a very powerful front-end server like Nginx handling the traffic instead, the request is processed faster. Check the “running Nginx on Windows PC” section for more details on IIS webserver’s role.

3.How Does Nginx Run in Windows?

Nginx supports multiple applications in Windows, such as web server, load balancer, mail proxy, and more. To run them in Windows, all desired changes are affected from various strings modified in the “nginx.conf” file in the Windows installation folder. To know more about Nginx commands, including the documentation, visit this link.

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.

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

Does Windows support NGINX?

Nginx is a web server that is very popular with Linux and BSD systems. It can also be installed on Windows 10.

Where should I install NGINX?

By default, NGINX will be installed in /usr/local/nginx . You may change this and other options with the Installation and Compile-Time Options.

Can I use NGINX in localhost?

nginx can be used to route requests to FastCGI servers which run applications built with various frameworks and programming languages such as PHP. This will set up a server that will route all requests except for requests for static images to the proxied server operating on localhost:9000 through the FastCGI protocol.