由于nginx自带的文件索引服务功能比较单一,所以一般采用Fancy Index插件,Ubuntu下安装Fancy Index插件的方法是
sudo apt-get install nginx-extras
安装完之后,修改站点配置文件如下:
location / {
fancyindex on;
fancyindex_exact_size off;
fancyindex_default_sort date_desc;
fancyindex_localtime on;
}
修改完成后, 重启nginx。
nginx -s reload
附nginx自带索引服务开启方法:
首先打开配置文件,不知道配置文件路径的同学可以使用一下命令获取路径:
nginx -t
打开nginx.conf配置文件后,开启文件索引服务的方法是,在http配置下加入:
http {
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
修改保存后,重启nginx服务即可。