Home  >  Q&A  >  body text

Problem with nginx reporting error when restarting under windows command line

Suppose you enter the following command on windows:

E:\mywamp\apache2.2\bin>E:\mywamp\nginx-1.6.2\nginx.exe -s reload

Then the input result is like this:

nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (3: The system cannot find the path specified)
2015/01/26 22:07:10 [emerg] 5164#5196: CreateFile() "E:\mywamp\apache2.2\bin/conf/nginx.conf" failed (3: The system cannot find the path specified)

The solution is to first cd to the directory E:\mywamp\apache2.2\bin>E:\mywamp\nginx-1.6.2\, and then run nginx -s reload, I feel like this is too troublesome. I would like to ask if there is an easier way.

漂亮男人漂亮男人2712 days ago1188

reply all(4)I'll reply

  • 滿天的星座

    滿天的星座2017-05-16 17:27:26

    nginx’s -c option can specify the path to the configuration file, so you can try specifying the absolute path when specifying the log file in the configuration file, such as E:mywampnginx-1.6.2logsaccess.log(prevent the log from opening Log file error), and then use the absolute path of the configuration file when executing nginx reload:

    shellE:\mywamp\nginx-1.6.2\nginx.exe -s reload -c E:\mywamp\nginx-1.6.2\conf\nginx.conf
    

    However, it seems that there are still problems above, all of which are path problems. nginx relies too much on the current path.

    Then try to find a way to reset the current directory before executing the nginx command. Under Windows, you can use the start command and the /D parameter to specify the starting directory. That will work. So just like thisstart /D E:mywampnginx-1.6.2 nginx -s reload

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 17:27:26

    First of all, since you choose nginx, don’t use it under windows. The efficiency is much worse than under Linux.

    Secondly, the reason why this file cannot be opened is obviously that the default relative path is not recognized. Modify the nginx.conf file and adjust the path address of access_log.

    Finally, it is recommended that the nginx command be added directly to the environment variables. The same is true under Linux. Please refer to Java to configure environment variables

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 17:27:26

    Add the parameter -p to specify the path and the solution will be perfect
    E:mywampapache2.2bin>E:mywampnginx-1.6.2nginx.exe -p E:mywampnginx-1.6.2 -s reload

    reply
    0
  • 迷茫

    迷茫2017-05-16 17:27:26

    Do not add Nginx to the path, create an nginx.cmd file under any of your own paths:

    @set nginx_path=D:\Local\Nginx
    @echo off
    pushd %nginx_path%
    if "%*" == "" (
      start /b %nginx_path%\nginx.exe
    ) else (
      call %nginx_path%\nginx.exe %*
    )
    popd

    The solution that suddenly came to my mind today, even though this problem has been around for two years (
    https://gist.github.com/hyrio...

    reply
    0
  • Cancelreply