LNMP安装fancyindex索引列表

  • 2
  • 6,769 views
  • A+
所属分类:工具资源

文件共享有很多方法,不过外链最方便的还是索引列表,相对于h5ai之类的目录程序来说nginx自带的索引列表并不漂亮,但是最大的好处就是可以脱离PHP执行,是纯静态的,对资源的占用几乎可以忽略不计。当然在美化nginx的索引列表上也可以使用第三方美化插件fancyindex。本文记录了军哥LNMP1.3下启用fancyindex的过程。

一、首先当然是安装LNMP环境了,其实单独nginx就可以用索引目录了,不过这里不讨论。

二、下载fancyindex到用户文件夹下,这里以root用户为例。

cd /root

git clone https://github.com/aperezdc/ngx-fancyindex.git

三、编辑/root/lnmp1.3-full下的lnmp.conf文件,Nginx_Modules_Options='--add-module=/root/ngx-fancyindex',保存

LNMP安装fancyindex索引列表

四、使用./upgrade.sh nginx升级脚本升级nginx程序,输入1.8.0,最新的nginx1.9.9没有尝试。自动升级完后使用nginx -V查看

LNMP安装fancyindex索引列表

看到已编译参数里有--add-module=/root/ngx-fancyindex就是成功了。

五、接下来添加虚拟主机vhost,然后编辑该虚拟主机配置文件

vim /usr/local/nginx/conf/vhost/xxx.conf,打开fancyindex,加入以下信息

location / {
fancyindex on;
fancyindex_exact_size off;
fancyindex_localtime on;
fancyindex_footer "/footer.html";
fancyindex_ignore "footer.html";
}

最后重载nginx配置文件就行了,service nginx reload。footer.html需要你自己编辑了,效果就是http://soft.vpser.net

参数解释:
fancyindex on:开启fancy索引
fancyindex_exact_size off:不使用精确的大小,使用四舍五入,1.9M会显示为2M这样.如果开启的话,单位为字节
fancyindex_localtime on:使用本地时间
fancyindex_footer /footer.html:把网站根目录下footer.html内容作为底部.文件不存在底部会出现404
footer.html内容如下:




fancyindex_ignore:哪些文件/目录隐藏掉

fancy指令使用:
fancyindex
语法: *fancyindex* [*on* | *off*]
默认值: fancyindex off
配置块: http, server, location
描述: 开启/关闭目录索引功能

fancyindex_css_href
语法: *fancyindex_css_href uri*
默认值: fancyindex_css_href “”
配置块: http, server, location
描述: 外置css路径,可以用这个css替代掉现有的css样式

fancyindex_exact_size
语法: *fancyindex_exact_size* [*on* | *off*]
默认值: fancyindex_exact_size on
配置块: http, server, location
描述: 定义如何显示文件的大小,默认是on,on:文件大小使用精确值,单位为字节.off:单位为KB,MB,GB,如果含有小数点,将会四舍五入。例如1.9MB,将会显示为2MB。

fancyindex_footer
语法: *fancyindex_footer path*
默认值: fancyindex_footer ""
配置块: http, server, location
描述: 指定哪个文件嵌入到索引页面的底部

fancyindex_header
语法: *fancyindex_header path*
默认值: fancyindex_header ""
配置块: http, server, location
描述: 指定哪个文件嵌入到索引页面的头部.用法和fancyindex_footer类似

fancyindex_ignore
语法: *fancyindex_ignore string1 [string2 [… stringN]]*
默认值: No default.
配置块: http, server, location
描述: 哪些文件/目录隐藏掉,支持nginx正则

fancyindex_localtime
语法: *fancyindex_localtime* [*on* | *off*]
默认值: fancyindex_localtime off
配置块: http, server, location
Description: 使用当地时间显示文件的创建时间,默认是off(GMT时间)

 

weinxin
我的微信公众号
我的微信公众号扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:2   其中:访客  0   博主  0

    • me me 0

      请问这个不能实现分页功能吗,所有文件挤在一页里很不方便啊

        • 厘米 厘米 9

          @me 这个就是最简单的目录,功能确实没有。你可以试试h5ai等程序!