Reputation: 557
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
for current working directory. Example: for http://mydomain.com/test/index.php
, I want c:/http_default/test/nginx.conf
to be included.
Upvotes: 5
Views: 9217
Reputation: 348
There is a program called incron, an "inotify cron" system. It detects file changes for a very low cost: inotify.
install incron, e.g. apt-get install -y incron
edit incrontab incrontab -e
add /var/www/site1/nginx.conf IN_MODIFY,IN_NO_LOOP /usr/local/sbin/nginx-reload.sh
adjust your webroot, it is more secure to set webroot to sitename/server and put this nginx.conf in the username dir
the shell script uses flock
to wait for the previous reload
flock -x "/var/lock/nginx-reload" -c nginx-reload-worker.sh
logger -t "nginx-reload[$$]" "Reloading OK"
the worker script delays every reload by 5 seconds
sleep 5
service nginx reload || error 2 "nginx reload error"
See all this in NGINX auto reload gist
Upvotes: 2
Reputation: 501
Your best option is to first have standardized directory structure (e.g. c:\www\example.com ). Then in each site directory have a directory for your root and for conf files. Then you'd use this in your main nginx.conf http { } section.
include c:/www/*/conf/nginx.conf;
Then each site's nginx.conf will get loaded when you start or issue a reload to nginx. So if you have these two paths for a site, you are set.
c:\www\example.com\conf\
c:\www\example.com\htdocs\
Web files go in htdocs and nginx.conf goes in conf. Simple as that.
I never used nginx on Windows, so I assume its' conf uses forward slashes like *nix.
Upvotes: 2