Categories
Windows

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 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.