nginx官网区别地址:
http://nginx.org/en/docs/http/ngx_http_core_module.html#root
http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
在配置Nginx静态资源时引发的问题(我对此配置的理解如下).....
先讲alias用法(配置如下)
location /request_path/
image
/ {
alias
/local_path/
image
/;
}
当客户端请求 /request_path/image/1.jpg的时候,
Nginx把请求映射为
/local_path/image/1.jpg
,
(直接将图片放入到/local_path/image/目录下)
详细请求:http://ip:port/request_path/image/1.jpg
先再看root用法(配置如下)
location /request_path/image/
{
root /local_path/image/
;
}
这样配置的结果就是当客户端请求 /request_path/image/1.jpg的时候,
Nginx把请求映射为
/local_path/image/request_path/image/1.jpg
(需要在 /local_path/image/目录下再创建/request_path/image/目录 然后将1.jpg放入该目录下)
详细请求:http://ip:port/request_path/image/1.jpg
然后检测nginx配置文件是否正确 :[root@localhost nginx]# ./sbin/nginx -t
然后重启nginx :[root@localhost nginx]# ./sbin/nginx -s reload