菏泽网站建设公司,做网站上面的图标,推荐中山精品网站建设,wordpress the author最近在使用Nginx配置一个图片静态服务器来通过http请求访问图片#xff0c;在配置的时候#xff0c;发现遇到访问有404的问题#xff0c;结果发现是在配置路径的时候#xff0c;和路径属性是root还是alias的有关。nginx配置文件server {listen 88;server_name localhost;#c…最近在使用Nginx配置一个图片静态服务器来通过http请求访问图片在配置的时候发现遇到访问有404的问题结果发现是在配置路径的时候和路径属性是root还是alias的有关。nginx配置文件server {listen 88;server_name localhost;#charset koi8-r;#access_log /var/log/nginx/host.access.log main;location /images/ {alias /var/www/app/static/;autoindex_localtime on; # 列表目录显示本地时间autoindex on;}location / {root /usr/share/nginx/html;index index.html index.htm;}}下面就是root和alias的配置的区别如果我们是在location中配置子目录/static/ 并且 root 后面加上文件地址location /static/ {root /var/www/app/static/;autoindex on;}这个情况解析的文件地址就会是 /var/www/app/static/static如果我们是在location中配置子目录/static/ 并且 alias 后面加上文件地址location /static/ {alias /var/www/app/static/;autoindex on;}这个情况解析的文件地址就会是 /var/www/app/static/如果我们location配置的是根目录使用root和alias效果是一样的如果我们配置的location是子目录这个时候我们就要考虑是使用root还是alias了。