nginx配置http静态站点服务器

1、  系统环境Windows 10

2、  设置静态站点目录,注意不要出现中文(这里踩了很多坑,可以查看错误日志error.log,

  “No mapping for the Unicode character exists in the target multi-byte code page”)

        

这里测试了一下目录

3、  配置nginx.conf

 server {

      listen        9001;

      server_name   localhost;

      access_log       logs/access/9001.log; #off;不记录请求日志

      charset              utf-8;

     

      location /{

               root E:/local/nginx/sites/9001;

      }       

      location /download/{

               root E:/local/nginx/sites/9001;

               autoindex         on;

               autoindex_exact_size      off;

               autoindex_localtime        on; 

      }

      error_page       404  ../404page/index.html;

}

监听端口:9001

站点目录:E:/local/nginx/sites/9001;

设置可以浏览目录的路径:download

404:跳转到指定404页面

 

中文目录和文件名会乱码,在Windows下暂时没找到决解方法。

原文地址:https://www.cnblogs.com/tongyi/p/11265532.html