使用nginx为静态资源提供服务

1.将项目或者静态资源(图片、视频、音频)放到nginx服务器上
image.png
2.配置nginx.conf
image.png
可配置多个location
root:指定访问路径
index:指定首页localhost:90/imooc// (*为imooc下的路径)
alias:配置别名 localhost:90/static// (*为imooc下的路径)

附: 使gzip压缩提升请求效率。

在nginx.conf文件中做如下操作

image.png

再附localtion匹配规则
image.png

评论

暂无评论