4.Nginx 的 location 与 root

2017-12-19  本文已影响0人  经纶先生

7./etc/nginx/conf.d/default.conf 配置文件:

    server {
        listen       80;
        server_name  www.zipeiyi.corp;

        location / {                            #代表在浏览器直接输入www.zipeiyi.com
            root   /usr/share/nginx/html;       #去找这个绝对路径目录下的index.html 
            index  index.html index.htm;
        }


        location /app.html {                  #代表访问www.zipeiyi.corp/app.html 
            root   html;                      #去找这个路径下的index.html 
            index  index.html index.htm;      #代表nginx安装目录下的html文件夹,比如说你nginx安装在了/opt/nginx 下,那么html代表的目录就为 /opt/nginx/html 
但是如果你写 root  /html   ,那就不是相对路径了(nginx安装目录下),那就是/html了  
        }

        error_page   500 502 503 504  /50x.html;    #定义的返回错误状态码是500 502的,统一跳转到50x.html这个页面
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

       
    }
上一篇 下一篇

猜你喜欢

热点阅读