nginx中root和alias区别
location /www/ {
alias html/www/;
}
location /www/ {
root html/www/;
}
在本例中:
- 使用alias,则不需要在目录
html/www/
下再建立一个wwww
目录 - 使用alias,必需要加
/
,不然后报错:/usr/local/nginx/html/wwwindex.html" failed (2: No such file or directory)
- 使用root,需要在目录
html/wwww/
下再建立一个wwww
目录,不然会报错:open() "/usr/local/nginx/html/www/www/index.html" failed (2: No such file or directory)