Heim  >  Fragen und Antworten  >  Hauptteil

Problem mit Nginx-Meldefehler beim Neustart unter der Windows-Befehlszeile

Angenommen, Sie geben unter Windows den folgenden Befehl ein:

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

Dann sieht das Eingabeergebnis so aus:

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)

Die Lösung besteht darin, zuerst in das Verzeichnis zu wechseln. E:mywampapache2.2bin>E:mywampnginx-1.6.2,然后运行nginx -s reload Ich denke, das ist zu umständlich. Ich würde gerne fragen, ob es einen einfacheren Weg gibt.

漂亮男人漂亮男人2712 Tage vor1197

Antworte allen(4)Ich werde antworten

  • 滿天的星座

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

    nginx的-c选项可以指定配置文件的路径,所以,你可以试试,在配置文件里面指定日志文件的时候指定为绝对路径,比如E:\mywamp\nginx-1.6.2\logs\access.log(防止日志打开日志文件错误),然后执行nginx reload的时候使用配置文件的绝对路径:

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

    不过,好像上面还有问题,都是路径方面的问题,nginx对当前路径的依赖太大。

    那么就想办法在执行nginx命令前重新设定当前目录吧,Windows下的话可以用start命令,/D参数指定起始目录,这样就行。所以像这样就行了start /D E:\mywamp\nginx-1.6.2 nginx -s reload

    Antwort
    0
  • 仅有的幸福

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

    首先,既然选用nginx就不要在windows下使用,效率比在Linux下差很多。

    其次,这个文件打不开的原因显然是默认相对路径不认,去修改nginx.conf文件,调整access_log的路径地址。

    最后,建议nginx这个命令直接加入到环境变量,在Linux下也一样意见这么做,参考Java配置环境变量

    Antwort
    0
  • PHP中文网

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

    加上参数-p指定路径完美解决不谢
    E:\mywamp\apache2.2\bin>E:\mywamp\nginx-1.6.2\nginx.exe -p E:\mywamp\nginx-1.6.2\ -s reload

    Antwort
    0
  • 迷茫

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

    不把 Nginx 加入 path,在你的任何一个自己的 path 下创建一个 nginx.cmd 文件:

    @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

    今天突然想到的解决方法,虽然这问题已经两年了(
    https://gist.github.com/hyrio...

    Antwort
    0
  • StornierenAntwort