linux 服务器 访问 静态文件的两种方式 nginx和tomcat

比如资源是一张图片,wnd.jpg,资源路径 /opt/pic/wnd.jpg

访问地址: http://ip:8080/pic/wnd.jpg
通过nginx配置
server {
listen 8080;
server server_pic;
location /pic {
   root /opt;
  autoindex on;
}
}

或者
server {
listen 8080;
server server_pic;
location /pic {
   alias /opt/pic;
  autoindex on;
}
}

tomcat 配置方式
在tomcat的conf下的server.xml的最后添加
<Context docBase ="/usr/local/EasyFit/picture/" path ="/pictures" debug ="0" reloadable ="true"/>
docBase资源的实际路径,path是访问路径
实际访问地址 服务器ip:tomcat端口/pictures/a.jpg

 

posted @ 2021-08-25 15:54  啦啦拉扎尔  阅读(875)  评论(0编辑  收藏  举报