Problem mit Nginx-Meldefehler beim Neustart unter der Windows-Befehlszeile
漂亮男人
漂亮男人 2017-05-16 17:25:26
0
4
1189

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.

漂亮男人
漂亮男人

Antworte allen(4)
滿天的星座

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

仅有的幸福

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

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

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

Ty80

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

迷茫

不把 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...

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!