# Nginx on Windows Server: install, test and run it as a service

> Unpack Nginx on Windows, test the config from the right directory, run it on 8081, and wrap it as a service without pretending it is Linux Nginx.

**Tested on**

- Build: 26100.33650
- Edition: Standard / Datacenter
- Architecture: x64
- Evidence: E1
- Verified: 2026-10-29
- Test machine: Nginx 1.28.0 on VM 361 Windows 11 26H2, port 8081; Server 2025 service wrapping E1

VM 361: Nginx 1.28.0 unpacked at `C:\nginx`, default page on `http://localhost:8081`. Windows 11 UI; Server 2025 service setup is E1.

## The short answer

Nginx on Windows is a **console application**, not a Windows service by default:

```bat
cd C:\nginx
nginx.exe -t
start nginx
nginx.exe -s reload
nginx.exe -s stop
```

The official Windows build is useful for a lab, an internal site or a compatibility tier. It is not feature-equivalent to Linux Nginx: no php-fpm, no HTTP/3 module, and fewer tuning options. Do not present it as a high-concurrency production edge.

## Install

1. Download the Windows zip from nginx.org.
2. Extract to `C:\nginx` (avoid `Program Files` spaces and ACL surprises).
3. Edit `conf/nginx.conf`; start with `listen 8081;` if IIS already owns 80.
4. Run `nginx -t` **from `C:\nginx`**, then `start nginx`.
5. Open the firewall only for the lab network.

The lab used:

```text
C:\nginx\nginx.exe -v   -> nginx/1.28.0
listen 8081
http://localhost:8081/  -> 200 "Welcome to nginx!"
```

## Why `nginx -t` fails from the wrong directory

Nginx resolves `conf/nginx.conf`, `logs/error.log` and relative `root` paths against its **working directory**. Running it from `C:\Windows\System32` produces:

```text
CreateFile() "C:\WINDOWS\system32/conf/nginx.conf" failed
```

That is not a broken install. `cd C:\nginx` first, or use absolute paths in the config/service wrapper.

## Run as a service

Use a wrapper such as WinSW or NSSM. Minimal WinSW intent:

- executable: `C:\nginx\nginx.exe`
- working directory: `C:\nginx`
- stop: `nginx.exe -s stop` (or wrapper’s stop command)
- account: a dedicated low-privilege account with read on `C:\nginx`, write on `logs` and `temp`
- startup: automatic, restart on failure

Do not run it as LocalSystem just because the service starts. Nginx only needs its own directories.

## Windows boundaries

| Topic | Windows Nginx |
|---|---|
| php-fpm | Not available; use PHP-CGI/FastCGI |
| HTTP/3 | `ngx_http_v3_module` cannot be built on Win32 |
| Performance | Not Linux-equivalent; test before claiming numbers |
| Service | Wrapper required |
| Signals | `nginx -s reload/stop`, not Unix signals |

> **Caution: Do not copy Linux paths**
>
> `/etc/nginx`, `/var/log/nginx`, `include /etc/nginx/...` do not exist here. Use `C:/nginx/conf/...` or forward-slash relative paths under `C:\nginx`.

## Verify

```powershell
cd C:\nginx
.\nginx.exe -t
Get-Process nginx
Invoke-WebRequest http://localhost:8081/ -UseBasicParsing | Select-Object StatusCode
Get-Content .\logs\error.log -Tail 20
```

## Lab boundary

Nginx 1.28.0 was unpacked and served on 8081 on Windows 11 26H2. Server 2025 role/firewall/service wrapping remains E1; no performance or HTTP/3 claim is made.

## Sources

- [nginx — Windows](https://nginx.org/en/docs/windows.html)
- [nginx — Beginner's guide](https://nginx.org/en/docs/beginners_guide.html)
- [nginx — Command-line parameters](https://nginx.org/en/docs/switches.html)

---

Source: https://winbook.fyi/en/server/web/nginx-install/
