Skip to content

Nginx on Windows

If you’re using Nginx on Windows, here’s how you can get started:


1. Download Nginx

  1. Go to the official Nginx download page.
  2. Download the latest stable version for Windows (e.g., nginx-x.x.x.zip).

2. Install Nginx

  1. Extract the downloaded ZIP file to a folder, such as C:\nginx.
  2. Open the nginx folder. You’ll see a structure like this:
    C:\nginx
    ├── conf
    ├── html
    ├── logs
    └── nginx.exe

3. Start Nginx

  1. Open a Command Prompt or PowerShell.
  2. Navigate to the Nginx directory:
    Terminal window
    cd C:\nginx
  3. Start Nginx:
    Terminal window
    nginx.exe
  • Nginx should now be running. Open your browser and go to http://localhost. You should see the default Nginx welcome page.

4. Basic Configuration

The main configuration file is conf\nginx.conf in the Nginx directory.

  1. Open the configuration file in a text editor:

    Terminal window
    notepad C:\nginx\conf\nginx.conf
  2. Modify it to suit your needs. For example, to set up a basic website:

    server {
    listen 80;
    server_name localhost;
    root C:/nginx/html;
    index index.html;
    location / {
    try_files $uri $uri/ =404;
    }
    }
  3. Save the file and reload Nginx:

    Terminal window
    nginx.exe -s reload

5. Create Your Website

  1. Place your HTML files in the html folder:
    • For example: C:\nginx\html\index.html.
  2. Access your site at http://localhost.

6. Stop Nginx

To stop Nginx:

Terminal window
nginx.exe -s stop

7. Run Nginx as a Windows Service (Optional)

Running Nginx as a service ensures it starts automatically with Windows.

  1. Use a tool like NSSM (Non-Sucking Service Manager) to register Nginx as a service. Download NSSM from https://nssm.cc/.
  2. Install the service:
    Terminal window
    nssm install nginx
  3. Configure the application path to C:\nginx\nginx.exe.

If you need help with a specific Nginx setup, feel free to ask!