</p><p align="left">此方法适用于OneinStack(LNMP)环境下编译安装Fancy Index模块,当然原理和方法类似,都可以参考。</p>一、下载模块
<p align="left">如果您已经安装好OneinStack(LNMP)一键包,默认情况是没有编译Fancy Index模块的,我们需要自己编译一下。</p>cd /root/lnmp/src ###进入LNMP一件包的src目录,请根据实自己的实际情况调整
git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex ###下载Fancy Index模块二、解压Ningx
<p align="left">Nginx的包也是在/root/lnmp/src目录下,使用下面的命令解压,注意:不同的版本nginx压缩包名字可能不一样,请根据实际情况修改。</p>tar -zxvf nginx-1.9.14.tar.gz ###解压nginx
cd nginx-1.9.14 ###进入nginx目录三、增加Nginx模块
<p align="left">先输入命令nginx -V查看当前已经编译的模块,并记录。</p><p align="left">
</p><p align="left">执行下面的命令在末尾增加--add-module=../ngx-fancyindex模块:</p>./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-ld-opt='-ljemalloc' --add-module=../ngx-fancyindex四、重新编译
<p align="left">依次输入下面的命令重新编译下nginx</p>make
mv /usr/local/nginx/sbin/nginx{,_`date +%F`}
cp objs/nginx /usr/local/nginx/sbin五、添加配置
<p align="left">将下面的配置文件添加到nginx主机配置文件中,并service nginx restart重启nginx</p>location / {
fancyindex on;
fancyindex_exact_size off;
fancyindex_localtime on;
#fancyindex_header \"/header.html\";
fancyindex_footer \"/footer.html\";
fancyindex_ignore \"footer.html\" \"exclude_centos.list\";
}
<p align="left">这样就可以利用Fancy Index模块模块美化Nginx索引目录啦,也可以自定义footer或者header页面,分享一下自己的footer.html文件:</p><style type = \"text/css\">
body{
margin:0;
padding:0;
font-size:16px;
font-family:'MicrosoftYaHei';
}
#foot{
font-size:14px;
width:100%;
position: fixed;
bottom:10px;
text-align:center;
padding:8px;
padding-top:20px;
/*border:1px solid red;*/
margin-top:20px;
}
a{
text-decoration:none;
}
</style>
<div id = \"foot\">
&#169;2016 Powered by <a href = \"https://www.cgzz8.cn/\" title = \"草根吧\" target = \"_blank\">草根吧</a>. <a href = \"../readme.html\" title = \"草根吧 - Discuz应用中心\">使用说明</a>
</div>
<script src = \"https://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js\"></script>
<script>
$(document).ready(function(){
var bodyheight = $(document.body).outerHeight(true);
var bheight = $(window).height();
//alert('body:' + bodyheight + 'browser:' + bheight);
if(bodyheight > bheight) {
$(\"#foot\").css(\"position\",\"relative\");
}
});
</script>
</body>
</html>六、效果演示
<p align="left">最后查看到的效果如下图所示,</p><p align="left">
</p>