在nginx服务器的root路径配置过程中总会遇到一些问题 1、相对路径的问题 源配置文件中对location ~ \.php${ root html } 此示例中的html是一个相对路径,相对的是这个配置文件的路径,假设此配置文件的位置是/etc/nginx/conf.d,那么这个html的绝对路径就是/etc/nginx/conf.d/html。在配置root路径的过程中最好用绝对路径。 2、路径的继承问题 假如server 中声明root /usr/share; 那么此时声明 location /{ root /usr/html/www } 此时就会覆盖掉server root 中的路径 假如此时声明 location /app { } 那么此时所有的操作就是基于路径/usr/share/app 3、首页的设置问题 假如我们在声明server 中声明 index index.html index.php 那么我们此时请求 / 就会在内部重定向到 url/index.php 或者 url/index.html 然后再由先关的location 进行匹配 之后再进行解析