[英]How to config nginx to read nginx.conf in current working directory?
I have intalled nginx on Windows and put an nginx.conf
in my http root directory, but it seems this path is not included, I can include it by including c:/http_default/nginx.conf
, but I want nginx to automaticaly include any nginx.conf
用于当前工作目录。 示例:对于http://mydomain.com/test/index.php
,我想c:/http_default/test/nginx.conf
有一个名为 incron 的程序,一个“inotify cron”系统。 它以非常低的成本检测文件更改: inotify 。
安装 incron,例如apt-get install -y incron
编辑 incrontab incrontab -e
添加/var/www/site1/nginx.conf IN_MODIFY,IN_NO_LOOP /usr/local/sbin/nginx-reload.sh
调整你的webroot,将webroot设置为sitename/server更安全,并将这个nginx.conf放在用户名中目录
shell 脚本使用flock
等待上一次重新加载
flock -x "/var/lock/nginx-reload" -c nginx-reload-worker.sh logger -t "nginx-reload[$$]" "Reloading OK"
工作脚本将每次重新加载延迟 5 秒
sleep 5 service nginx reload || error 2 "nginx reload error"
在NGINX 自动重新加载要点中查看所有这些
您最好的选择是首先具有标准化的目录结构(例如 c:\www\example.com )。 然后在每个站点目录中都有一个目录用于您的根目录和 conf 文件。 然后你会在你的主要 nginx.conf http { }部分中使用它。
include c:/www/*/conf/nginx.conf;
然后每个站点的 nginx.conf 将在您启动或重新加载到 nginx 时被加载。 因此,如果您有这两个站点路径,那么您就设置好了。
c:\www\example.com\conf\
c:\www\example.com\htdocs\
Htdocs 中的 Web 文件go和nginx.conf进入 conf。 就那么简单。
我从未在 Windows 上使用过 nginx,所以我假设它的 conf 使用像 *nix 这样的正斜杠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.