在C:pleiades ginx-1.16.1下新建一个目录files,然后放入若干文件,接下来修改nginx.conf,增加粗体字如下:
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; access_log logs/access.log; sendfile on; keepalive_timeout 65; autoindex on;# show folder autoindex_exact_size on;# show file size autoindex_localtime on;# show file modification time server { listen 80; server_name localhost; root files; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
然后在浏览器中输入localhost,会出现下面效果:
直接把根路径做成文件服务器可能不太好,增加一个server如下修改也行:
autoindex on;# show folder autoindex_exact_size on;# show file size autoindex_localtime on;# show file modification time server { listen 9999 default_server; listen [::]:9999 default_server; server_name _; root D:Usersos-ufosoftware; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
--END-- 2019-12-17 17:58