1、安装nginx后,在/etc/nginx/conf/conf.d目录寻找.conf文件,编辑它。
vim /etc/nginx/conf/conf.d/a.conf
2、在该文件下的server处,或者某个location以下,粘贴如下代码。
autoindex on; #开启目录浏览 autoindex_format html; #以html风格将目录展示在浏览器中 autoindex_exact_size off; #切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB autoindex_localtime on; #显示服务器的的时间 charset utf-8,gbk; #中文文件名
3、重新启动nginx
service nginx restart