将nginx.exe文件拖入命令行窗口,回车运行后,出现以下错误提示:
nginx:
[alert] could not open error log file: CreateFile() "logs/error.log" failed
(3: The system cannot find the path specified)
2016/10/17 15:52:21
[emerg] 7204#2148: CreateFile() "C:\Windows\system32/conf/nginx.conf" failed
(3: The system cannot find the path specified)
网上搜索了一下相关资料,在梦中梦的博文“windwos nginx 不在exe目录运行的错误”中找到了一丝线索,博文地址如下:
http://meiyitianabc.blog.163.com/blog/static/1050221272013615253563
文中写道,出现这个错误提示的原因是我们把nginx的目录加入到系统环境变量的path中去了,然而nginx启动时各种路径都是以当前工作目录为起点的,这就导致了系统去"C\Windows\system32/conf/nginx.conf"这个地方去寻找配置文件,而不是正常的"nginx安装路径/conf/nginx.conf"。
我这才想起来,之前为了能够在命令行窗口下输入nginx回车启动nginx,我把nginx安装路径加入了系统环境变量的path中去了。当下我就打开系统环境变量,把nginx安装路径移除了。心想这下应该大功告成了吧……
不错……如你所料,我又遇到了新的问题——计算机的错误总是层出不穷。当我再次尝试之前的操作,系统给出了以下错误提示:
nginx:
[alert] could not open error log file: CreateFile() "logs/error.log" failed
(3: The system cannot find the path specified)
2016/10/17 16:11:05
[emerg] 7536#5292: CreateFile() "C:\Users\T/conf/nginx.conf" failed
(3: The system cannot find the path specified)
乍一看,还以为是同一个错误。仔细看了下,上个错误提示中的:
[emerg] 7204#2148: CreateFile() "C:\Windows\system32/conf/nginx.conf" failed
(3: The system cannot find the path specified)
路径改变了,变成了:
[emerg] 7536#5292: CreateFile() "C:\Users\T/conf/nginx.conf" failed
(3: The system cannot find the path specified)
有了前面的经验,我自然地打开环境变量去检查用户环境变量(前面是系统环境变量),结果,在用户环境变量的path中并没有找到nginx的安装路径,一时之间我有些不知所措了。
----------------------------- 分割线 -----------------------------
写了个简单的启动nginx.exe的bat脚本,结果呢,这个脚本放在nginx安装路径下运行可以成功地启动nginx,放在其它目录就失效了,这……顿时我就凌乱了。
好吧,不玩了,老老实实地进nginx安装目录启动它吧。