打开对应的虚拟主机的nginx配置文件,在root配置下面添加如下几行即可,具体看下面
root /Users/ieras/Sites/default;
#开启目录浏览功能;
autoindex on;
#关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b;
autoindex_exact_size off;
#开启以服务器本地时区显示文件修改日期
autoindex_localtime on;
当然这么配是从根目录就开始展示了,如果你只想展示特定目录的列表也可以这么配置,如下
location /show_dir {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
这样的话就只有访问 你的域名/show_dir 时候才会展示内容列表。。。
效果如下:
