Can't run the Nginx executable file

I've installed Nginx web server on my machine under Windows 7 with php.

When I start the "nginx.exe", the command prompt opens for a second and then closes automatically, so I can't control it through the command prompt. Couldn't find a solution anywhere.

What I want is to open the "nginx.exe" and use various commands there.

Otherwise the server is working.

Upvotes: 14

Views: 21885

Answers (2)

ecdani
ecdani

Reputation: 355

I made a different version of the script of Larry Lane. With this version you can invoke nginx from any path.

The script needs to be in any route accessible via Windows path and should be named nginx.bat.

@echo off
SET var=%cd%
cd C:/nginx
nginx %*
cd %var%

Execution example:

Execution example

Upvotes: 1

Larry Lane
Larry Lane

Reputation: 2191

  1. First you need to know the path to your nginx.exe file.

  2. Once you have that right click on your desktop and click on the new text document.

  3. Then type or paste in the following text:

c:\
cd c:\nginx
start nginx.exe
cmd /k
  1. Now save the file with whatever name you want to use but add the .bat extension to it. Example nginx.bat

  2. Now you can click on the file and it should open the command prompt, change the directory, start the server, and then leave the prompt open in the correct directory so you can run your commands.

Upvotes: 7

Related Questions