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.

1

2 Answers

  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.

6

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest