Nginx is a very popular web server on Linux and BSD systems. It can also be installed on Windows 10. However, until now, some performance limitations in Windows have not been alleviated, but the developers will resolve these issues in future releases. To successfully install and run Nginx on Windows, please follow the steps below.
Download the Nginx Server
There are many download versions of Nginx for Windows, and Nginx recommends using the “major version”. However, if you download the latest stable version for Windows, you will not encounter any problems.
Select the version you want and download its zip file to your PC.
As a first step, you need to extract the new folder. You can use 7-zip, WinRAR or any other popular compression software.
After extracting the contents of the archive to the original folder, you need to move the entire folder that came with the embedded download copy to the “Program Files”. We can move or cut and paste this extracted folder.
We will run Nginx from this location as a default web service program.
To install and run Nginx, select and double-click the Nginx.exe file. It has now been activated for later use. When running Nginx server, you may encounter Windows Defender lock screens, which must be approved by you.
The next step is to verify if the installation was successful. To do this, go to your default browser and enter localhost. Microsoft Edge is the browser used in the following example. If you see the screen that shows that the Nginx web server has been installed correctly and is working normally, it means that you have no problem installing Nginx on Windows.
To stop Nginx, you can end it from the Task Manager window.
Running Nginx on Your Windows PC
To run Nginx, you must use Internet Information Services (IIS), which is a Microsoft web server that can serve requested HTML files or pages. You can enable it in “Turn Windows functions on or off” in the control panel. Check the required fields for “Web Administration Tool” and “IIS Administration Console”.
It will take a while for IIS to be enabled on your computer as the changes are applied.
You can open IIS Manager directly from the Start menu. Always open it in Administrator mode.
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.
It is useful to change the physical path of this root directory to a more ideal folder. I created a new “Work” folder in C: and changed the physical path to “C:\Work”. When you double-click the “Default Web Site” option in IIS Manager, it should point to this new folder. Alternatively, you can right-click the menu and select “Explore” to get the same result.
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.
In Notepad++, find the location of the root and change it from the default html.
As shown here, change the root to the edited physical path which we discussed above.
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.
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.
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 on Windows to link to a web page, such as a customer login page. After making configuration changes to the “nginx.conf” file, your end users will be able to access the login page.
Go back to the “nginx.conf” file shared in the previous section. You need a domain name for the server to access, not “localhost”. “Index.html” is a command used to point to any static html page.
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.
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:
||Changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes|
||Reopening log files|
2. What is the role of IIS Webserver in Nginx applications in Windows?
IIS is Microsoft’s native web server, supports HTTP, HTTPS, SMTP, and other protocols, and is not enabled by default on Windows. When Nginx is installed on Windows, it processes traffic in real time based on changes made to the nginx.conf file. To do this, Nginx must internally connect to the enabled IIS and then cache its response for any future requests.
The biggest advantage of Nginx lies in its use of front-end before high-load dynamic sites. Imagine thousands of website users download an important video file from IIS at the same time. It may become very slow. If you have a very powerful front-end server, such as Nginx to handle traffic, the request processing speed will be faster. For more detailed information about the IIS Web server role, please refer to the “Running Nginx on a Windows PC” section.
3.How Does Nginx Run in Windows?
Nginx supports multiple applications on Windows, such as web server, load balancer, mail proxy, etc. To run on Windows, all required changes will be affected by various modified strings in the “nginx.conf” file in the Windows installation folder. To learn more about Nginx commands, including documentation, please visit this link.
Nginx is one of the leading web server companies today. In addition, it is faster, can handle more concurrency issues, and is reliable. All in all, if you have a simple website that wants to connect to Nginx, you can do so now without any problem.