index:位置http、server、location作用指定网站的首页当访问的资源是一个文件夹时会使用index的指定的文件名称在文件夹内查找文件并返回可以指定多个文件名称按顺序查找生效规则当在http和server和location中都存在index时就近原则最近的index生效locationserverhttp默认值index.htmlroot:位置http、server、location作用指定资源查找的根目录生效规则当在http和server和location中都存在root时就近原则最近的root生效locationserverhttp默认值htmlroot指定相对路径资源根目录 nginx 安装路径 root路径资源路径资源根目录uri若资源路径对应的是一个文件夹index生效查找index对应的文件并返回nginx安装路径/etc/nginx/roottest;uri/pages/page.html资源根目录/etc/nginx/test/资源路径/etc/nginx/test/pages/page.html定位一个文件直接返回如果page.html是一个文件夹此时会去找这个文件夹下index指定的文件root指定绝对路径资源根目录 root 路径资源路径资源根目录uri若资源路径对应的是一个文件夹index生效查找index对应的文件并返回root/usr/share/nginx/html;uri/ 或空资源根目录/usr/share/nginx/html资源路径/usr/share/nginx/html/index.html