Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to config nginx to read nginx.conf in current working directory?

Tags:

nginx

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.

like image 422
IVIR3zaM Avatar asked Oct 10 '22 06:10

IVIR3zaM


1 Answers

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.

like image 95
SleighBoy Avatar answered Oct 18 '22 07:10

SleighBoy