How to set up the Nginx web server on Windows
Do you need to get the Nginx web server up and running on your Windows server? As it turns out, getting Nginx installed and running on the Windows server platform is easier than ever. Here’s how to get it working on your system.
How to download the Nginx web server on Windows Server
Head to the official download page to get Ngnix on your Windows Server. Once there, select the latest Windows version, and download it to your server. The download should be quick as it is not very large.
When the download is complete, open up Windows Explorer, and select the “Downloads” folder. Then, move the ZIP archive file into the “C:/” drive. Once the file is placed, open up the Powershell application. Powershell is required to configure the software.
Inside the Powershell app, install the “Expand-Archive” tool in Powershell with the following command.
Get-Command Expand-Archive
After installing Expand-Archive, extract the Nginx file you placed in “C:/.”
Expand-Archive -Path C:\nginx-1.23.2.zip -DestinationPath C:\ -Verbose
The extraction process should happen fast. When the process is complete, run the clear command to clear the prompt of all other commands. You can then run the cd command to move into the “nginx-1.23.2” folder.
clear
cd .\nginx-1.23.2\
Once inside of the folder, run the ls command to view all of the contents of the Nginx folder on the “C:/” drive on Windows Server. Nginx.exe should now be running in the background on Windows Server. You can check this with the GUI task manager included with Windows Server or the ps command in Powershell.
How to configure Nginx web server on Windows Server
The Nginx web server doesn’t require much configuration out of the box in Windows Server. However, we’ll still need to go over the basics (where the web server data is placed, etc.)
Nginx on Windows works a little differently than on Linux. Instead of the /var/www/
folder, Nginx sets itself up where it was initially launched. So, as Nginx was launched from C:\nginx-1.23.2\, the “HTML” folder in which web pages are served is located in:
C:\nginx-1.23.2\html\
Similarly, the configuration file folder for Nginx is located in C:\nginx-1.23.2\conf\
, the log files are stored in C:\nginx-1.23.2\logs\
, etc. To access these files for modification purposes, open Windows Explorer, select “C:\nginx-1.23.2\
” and go from there.
How to manage Nginx on Windows Server
You will need to know a few commands to manage the Nginx web server on Windows Server. To start, open up the Windows Explorer app and navigate to “C:\nginx-1.23.2”
Once you’ve accessed the folder, hold down the Shift key, and right-click on a blank space. Then, select “Open PowerShell window here.” Once Powershell is open, you can use the following commands to control Nginx.
./nginx.exe -s stop : Shut down the server fast.
./nginx.exe -s quit : Shut down the server "gracefully."
./nginx.exe -s reload : Change configuration, start a new process, etc.
./nginx.exe -s reopen : Run this to re-open log files.
How to edit the Nginx homepage on Windows Server
Like every web server, the Nginx web server provides a default “index.html” file. You can access this file at localhost/index.html. This file is the default page shown in the web directory when the address is specified.
For example, if you navigated to https://your-windows-server/somefolder/, it would automatically show you the “index.html” or “index.htm” file in that folder. If you’d like to customize the index.html file, do the following.
First, open Powershell. Then, use the cd command to access the Nginx folder on the “C:/” drive in Windows Server.
cd C:/nginx-1.23.2/
After accessing the Nginx folder on the “C:/” drive, you will need to load up the “html” folder. To do this, run the cd command again in the Powershell window.
cd html
You can open the “index.html” file inside the Notepad app for editing purposes. Once it is open, you can delete what Nginx puts and make your own custom page for your web server.
notepad index.html
Once you’ve finished editing your files in Notepad, you can save them by pressing Ctrl + S on the keyboard. This keyboard combination should save your edits to the “index.html” file.
When you’ve saved your edits, open a web browser and navigate to the following URL to view your handiwork.
http://your-windows-server-ip/
How to uninstall Nginx from your Windows Server
To uninstall Nginx from Windows Server, ensure that “nginx.exe” is no longer running. Once it is shut down, you can delete the Nginx folder in the “C:/” drive. However, ensure all data and configuration files are backed up before deleting them in case you wish to redeploy your web server later.