how is Nginx finding default root
0
I just installed nginx using brew and its default config is located at /usr/local/etc/nginx. The server configuration in default conf file is as below (only small portion pasted)
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
...
}
The location from which the index.html is being served is /usr/local/var/www/. Now, looking at the above configuration, I don't understand how nginx goes to /usr/local/var/www/ to look for default file? Is there a different configuration that directs nginx to look into that folder?
Add a comment
1
- If a value of the root directive is relative, the full path is composed using the nginx prefix. See that answer for details.
- In the nginx Homebrew formula the
--prefixis set to the Homebrew prefix:
--prefix=#{prefix}
- The default Homebrew prefix is
/usr/localon Intel. - Thus, the root is
html→/usr/local/html(the nginx prefix + the relative path). - In the nginx Hombebrew formula this location is symlinked to
#{HOMEBREW_PREFIX}/var/www, that is, to/usr/local/var/www:
# nginx's docroot is #{prefix}/html, this isn't useful, so we symlink it # to #{HOMEBREW_PREFIX}/var/www. The reason we symlink instead of patching # is so the user can redirect it easily to something else if they choose.
这个prefix 可以通过nginx -V命令看到
海纳百川 ,有容乃大

浙公网安备 33010602011771号