Logo ByteGopher
Logo Inverted Logo
  • Tags
  • Bson
  • ElasticSearch
  • Go
  • HTTPS
  • Hbase
  • Hexo
  • Http
  • Mongo
  • Nginx
  • OpenTSDB
  • Raft
  • TSDB
  • Tips
  • Vim
Hero Image
「Nginx」 Tips

搭建静态资源服务器 静态资源文件夹 1/root/file Nginx 配置 vi /etc/nginx/nginx.conf 1location /file { # 这个file 跟资源路径的名字没有半毛钱关系,可以不同 2 alias /root/file; # 静态资源的绝对路径 3 autoindex on; # 自动创建目录 4} 为了提高文件的传输效率,降低带宽浪费,可以开启gzip压缩 1gzip on; 2gzip_minPlength 1; # 小于1字节不压缩, 3gzip_comp_level 2; # 压缩级别为2 4gzip_types taxt/plain applicaton/x-javascripts txt/css application/xml image/jpeg image/gif image/png; # 压缩文件类型 重启nginx服务 1nginx -s reload 2# or 3systemctl restart nginx.service 通过浏览器访问资源 此时还有很多小伙伴大概率会遇到403 Forbidden, 试过将资源文件夹设置为777 -R 权限或者chown -R nginx:nginx file。But, still doesn’r work。 目前的解决方法是将/etc/nginx/nginx.conf 中的user 设置为root 。

July 31, 2020 Read
Navigation
  • About
  • Skills
  • Recent Posts
  • My Story
Contact me:
  • renqiqiang@outlook.com

Stay up to date with email notification

By entering your email address, you agree to receive the newsletter of this website.

Toha Theme Logo Toha
© 2020-2022 Copyright.
Powered by Hugo Logo