每次建新项目都会在配nginx时浪费时间,配好之后没留文档记录,导致下次继续浪费时间,今次就书面总结了却顽疾。
1. root
如果用root,若访问location路径,则定位到:root 路径 + location路径,下例中就是:
/usr/local/nginx/test/index.html
location /test {
root /usr/local/nginx;
index index.html index.htm;
}
2. alias (别名)
如果用alias,若访问location路径,则定位到alias路径
location /test {
alias /usr/local/nginx;
index index.html index.htm;
}
//最终路径:usr/local/nginx/index.html
location /test {
alias /usr/local/nginx/test;
index index.html index.htm;
}
//最终路径:usr/local/nginx/test/index.html
location /test2 {
alias /usr/local/nginx/test1;
index index.html index.htm;
}
//访问/test2 , 最终路径:usr/local/nginx/test1/index.html
阿里云服务器Nginx配置
本文详细介绍了在阿里云服务器上使用Nginx配置站点的过程,对比了root与alias两种方式的区别,提供了具体实例帮助理解如何高效配置Nginx,避免重复工作。
768

被折叠的 条评论
为什么被折叠?



