码迷,mamicode.com
首页 > 其他好文 > 详细

nginx配置文件中,location字段里面的root和外面root的区别

时间:2018-07-13 01:17:04      阅读:1985      评论:0      收藏:0      [点我收藏+]

标签:index   root   相对路径   listen   主页   img   www.   server   虚拟   

 

1. location里面的root例子

server{
         listen 80;
         server_name www.wzw.com;

         location /www {
                 root /data/;  //设置虚拟主机主目录相对路径
                 index  index.html;  //设置虚拟主机默认主页
         }
}

这个配置表示输入 www.wzw.com:80/www 时会访问本机的/data/www/ 目录去找文件

 

2. location里面的alias例子

server{
                listen 80;
                server_name www.wzw.com;

                location /img/ {
                        alias /var/www/image/;
index index.html; } }

当输入www.wzw.com:80/img时,会去本机的/var/www/image/找文件,需要注意的是用alias时,目录最后的/一定要有,而用root时可有可无

 

nginx配置文件中,location字段里面的root和外面root的区别

标签:index   root   相对路径   listen   主页   img   www.   server   虚拟   

原文地址:https://www.cnblogs.com/regit/p/9302568.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!