使用Nginx搭建静态资源WEB服务器
文章目录
一、下载一个静态WEB资源示例
从这个网站中可以下载dclib的静态资源示例:
https://sourceforge.net/projects/dclib/
二、将静态资源放到nginx目录下
/dev/servers/nginx/dlib
$tree dlib | more
dlib
├── CMakeLists.txt.html
├── algs.h.html
├── all
│ └── source.cpp.html
├── any
│ ├── any.h.html
│ ├── any_abstract.h.html
│ ├── any_decision_function.h.html
│ ├── any_decision_function_abstract.h.html
│ ├── any_function.h.html
│ ├── any_function_abstract.h.html
│ ├── any_function_impl.h.html
│ ├── any_function_impl2.h.html
│ ├── any_trainer.h.html
│ └── any_trainer_abstract.h.html
├── any.h.html
├── appveyor
......
三、配置Nginx
-
配置需要监听的端口
-
配置一个location
配置的时候一定要注意语法问题,使用“;”结尾
可以使用
./sbin/nginx -t检查语法是否有问题server { listen 8088; server_name localhost

本文详细介绍了如何使用Nginx搭建静态资源WEB服务器,包括下载静态资源、放置到Nginx目录、配置Nginx监听端口、配置location以及启用autoindex、限速和access日志等功能。同时,文章还讨论了GZIP压缩对资源大小的影响。
最低0.47元/天 解锁文章
811

被折叠的 条评论
为什么被折叠?



