【问题标题】:Nginx custom config file setting doesn't work when firing up the server启动服务器时,Nginx 自定义配置文件设置不起作用
【发布时间】:2019-01-23 03:09:47
【问题描述】:

我正在尝试在 Windows 7 64Bit 上配置 Nginx,PHP,以便 PHP 和 Nginx 都应该始终使用我在启动期间或在配置文件中指定的路径。

现在对于 Nginx,我正在使用以下 VBScript 启动它的服务器可执行文件,用于加载自定义配置文件:

... Vbs code ...
sh.run "cmd /K CD "& NginxPath &" & start nginx", 0
sh.run "cmd /K CD "& NginxPath &" & start nginx -c "& NginxConf, 0
sh.run "cmd /K CD "& NginxPath &" & start nginx -s reload", 0
... Vbs code ...

但它总是抛出相同的错误:

2019/01/21 06:53:52 [emerg] 6988#5196: CreateFile() "Custom\Path\mime.types" failed (2: The system cannot find the file specified) in Custom\Path\nginx.conf:18

即使出现此错误,服务器也会启动但会加载默认配置文件,这根本不应该发生。

顺便说一句,变量 NginxPath 和 NginxConf 都有正确的 Windows 路径和正确的双引号(例如“C:\path\file.conf”)

即使我们忘记了 VBscript,只是在 CMD 中触发以下命令,它也会给出相同的错误:

nginx -c C:\custom\path\nginx.conf

错误

nginx: [emerg] CreateFile() "C:\custom\path\mime.types" failed (2: The system cannot find the file specified) in C:\custom\path\nginx.conf:18

那么为什么会发生这种情况以及如何使用我想要的自定义 conf 文件来解决它?

【问题讨论】:

  • 这个问题属于SuperUser,因为它是关于程序配置问题,而不是关于编程问题。

标签: nginx cmd vbscript config nginx-config


【解决方案1】:

我认为您的自定义 nginx 配置文件中的某处存在以下行:

include       mime.types;

尝试将此文件的完整路径(位于默认配置文件所在的同一文件夹中)添加到此 include 指令:

include       C:/path/to/default/config/mime.types;

或者,您可以将mime.types 文件的副本放置到您的自定义配置文件所在的同一文件夹中。

【讨论】:

  • 是的,作为解决试验问题的第一步,我这样做了,但随后它会逐步要求该文件夹的每个文件,所以请让我知道一劳永逸的解决方案,那真的很有帮助。谢谢!!
  • 我不知道该怎么做,也许您可​​以将脚本中的当前目录更改为默认的 nginx 配置,然后 nginx 会在当前目录中查找每个包含的文件? (不确定,但值得一试)
猜你喜欢
  • 1970-01-01
  • 2015-09-26
  • 2012-12-06
  • 2011-07-26
  • 1970-01-01
  • 2016-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多