Installing Nginx on Windows 11
Complete guide to installing and configuring Nginx on Windows 11

Prerequisites
- A Windows 11 machine with administrative privileges
- A stable internet connection
- At least 50MB of free disk space
Step 1: Download Nginx
- Open a web browser and go to the official Nginx website: https://nginx.org/en/download.html
- Under the Mainline version section, download the latest stable Windows zip file (
nginx-x.x.x.zip).- Note: The mainline version contains the latest features, while the stable version prioritizes reliability.
Step 2: Extract the Nginx Files
- Locate the downloaded zip file in your Downloads folder.
- Right-click the file and select Extract All….
- Choose a destination folder (e.g.,
C:\nginx) and click Extract.- Tip: Avoid installing in folders with spaces in the path (like “Program Files”) to prevent potential issues.
Step 3: Configure Nginx
- Navigate to the extracted folder (
C:\nginx). - Open the
conffolder and locatenginx.conf. - Open
nginx.confin a text editor like Notepad or VS Code. - Important settings you might want to modify:
listendirective (line ~36) to change the default port from 80server_namedirective to set your domain namerootdirective to point to your website filesworker_processes(line ~2) to match your CPU cores for better performance
Example configuration for a basic website:
server {
listen 80;
server_name example.com www.example.com;
location / {
root C:/websites/mysite;
index index.html index.htm;
}
}
Step 4: Start Nginx
- Open Command Prompt as Administrator (right-click on Command Prompt and select “Run as administrator”).
- Navigate to the Nginx directory using the command:
cd C:\nginx - Start the Nginx server with:
start nginx - To verify that Nginx is running:
- Open a web browser and go to
http://localhost - You should see the Nginx welcome page
- Alternatively, check if the Nginx process is running with
tasklist /fi "imagename eq nginx.exe"
- Open a web browser and go to
Step 5: Manage Nginx
- Stop Nginx:
nginx -s stop - Reload configuration (after making changes):
nginx -s reload - Quit gracefully (wait for workers to finish):
nginx -s quit - Test configuration validity:
nginx -t
Step 6: Add Nginx to System Path
To run Nginx commands from any location:
- Press Win + X and select System.
- Click Advanced system settings on the right.
- Click Environment Variables button.
- Under System Variables, select
Pathand click Edit. - Click New and add the full path to your Nginx installation (e.g.,
C:\nginx). - Click OK to save all changes.
Step 7: Set Up Nginx as a Windows Service (Recommended)
Installing Nginx as a service allows it to start automatically with Windows:
- Download the Windows Service Wrapper (nssm) from https://nssm.cc/download
- Extract the zip file and navigate to the appropriate folder (32 or 64-bit)
- Open Command Prompt as Administrator and navigate to the nssm folder
- Install Nginx as a service:
nssm install nginx - In the NSSM dialog:
- Set the Path to
C:\nginx\nginx.exe - Set Startup directory to
C:\nginx - Click Install service
- Set the Path to
- Now you can manage Nginx with:
net start nginx net stop nginx
Troubleshooting
- Port 80 already in use: Change the port in
nginx.confor stop the service using port 80 (often IIS or Skype) - Access denied errors: Ensure you’re running commands as Administrator
- Configuration errors: Run
nginx -tto validate your configuration - Nginx won’t start: Check the error logs in
C:\nginx\logs\error.log - 404 errors: Verify your path settings in the configuration and ensure files exist
Security Considerations
- Change default error pages to avoid revealing server information
- Implement SSL/TLS for secure connections
- Limit access to sensitive directories
- Consider adding basic authentication for admin areas
Conclusion
You have successfully installed and configured Nginx on Windows 11. You can now use it as a web server, reverse proxy, load balancer, or caching server for your applications.