0
0
NginxHow-ToBeginner · 4 min read

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.exe to start the server.
  • Stop: Use nginx.exe -s stop to 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.exe without 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.exe outside 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.exe
Output
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.org for the latest stable version.
  • Extract to a simple path like C:\nginx to avoid permission issues.
  • Run nginx.exe from the extracted folder using Administrator rights.
  • Use nginx.exe -s stop to stop the server cleanly.
  • Check conf/nginx.conf to 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.