How to Install Nginx on Windows: Step-by-Step Guide
To install
nginx on Windows, download the official Windows zip package from the nginx.org website, extract it, and run nginx.exe from the extracted folder. This starts the server, which you can verify by opening http://localhost in your browser.Syntax
The basic steps to install and run nginx on Windows are:
- Download: Get the official Windows zip file from
https://nginx.org/en/download.html. - Extract: Unzip the package to a folder, e.g.,
C:\nginx. - Run: Open Command Prompt, navigate to the folder, and run
start nginx.exeto start the server. - Stop: Use
nginx.exe -s stopto stop the server.
batch
cd C:\nginx start nginx.exe nginx.exe -s stop
Example
This example shows how to download, extract, and start nginx on Windows using Command Prompt.
batch
curl -Lo nginx.zip https://nginx.org/download/nginx-1.24.0.zip powershell -Command "Expand-Archive -Path nginx.zip -DestinationPath C:\nginx" cd C:\nginx\nginx-1.24.0 start nginx.exe REM Open http://localhost in your browser to see the welcome page REM To stop nginx: nginx.exe -s stop
Output
Starting nginx...
(Opening http://localhost shows the default nginx welcome page)
Common Pitfalls
- Not running as Administrator: Starting
nginx.exewithout admin rights can cause permission errors. - Port conflicts: If port 80 is used by another app, nginx won't start. Change the port in
conf/nginx.conf. - Wrong folder: Running
nginx.exeoutside the extracted folder causes errors because config files are missing.
batch
REM Wrong way (running outside nginx folder):
cd C:\
nginx.exe
REM Right way:
cd C:\nginx\nginx-1.24.0
nginx.exeOutput
nginx: [emerg] open() "/conf/nginx.conf" failed (2: No such file or directory)
Quick Reference
Summary tips for installing and running nginx on Windows:
- Always download from
nginx.orgfor the latest stable version. - Extract to a simple path like
C:\nginxto avoid permission issues. - Run
nginx.exefrom the extracted folder using Administrator rights. - Use
nginx.exe -s stopto stop the server cleanly. - Check
conf/nginx.confto customize ports or settings.
Key Takeaways
Download the official nginx Windows zip from nginx.org and extract it.
Run nginx.exe from the extracted folder with Administrator rights to start the server.
Open http://localhost in a browser to verify nginx is running.
Stop nginx cleanly using nginx.exe -s stop command.
Check and edit conf/nginx.conf to fix port conflicts or customize settings.