Fancyindex+Nginx,打造自己的简约下载站

原创 wuwenwu  2016-05-18 02:44  阅读 3,336 次

近期折腾了一个下载站,用来方便大家和自己,存储一些东西,地址:http://yun.laifengba.com/

关于Fancyindex模块美化Nginx的Index的功能已经到处都是了,百度上一下就行,简单总结下安装教程。

  • 1.准备一个纯净的Linux环境,编译nginx,不会的话直接安装LNMP就行,
  • 推荐:军哥一键包 下载地址 :http://lnmp.org/download.html
  • 2.安装Fancyindex模块。
  1. wget http://nginx.org/download/nginx-1.9.13.tar.gz
  2. tar -xzvf nginx-1.9.13.tar.gz
  3. git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex
  4. nginx -V //得到Nginx的参数,全部复制
  5. cd nginx-1.9.13
  6. ./configure --add-module=../ngx-fancyindex 你刚才复制的参数
  7. make
  8. make install
  • 3.LNMP新建一个主机,不需要数据库,和普通开通虚拟主机一样的步骤。
    4.修改conf文件。
  1. server {
  2. listen       80;
  3. server_name  down.laifengba.com;
  4. index index.html index.php index.html;
  5. root /data/wwwroot/down.laifengba.com;
  6. fancyindex on;
  7. fancyindex_exact_size off;
  8. fancyindex_localtime on;
  9. fancyindex_footer /footer.html;
  10. fancyindex_header /header.html;
  11. fancyindex_ignore footer.html header.html;
  12. }
  • 完成后重启Nginx service nginx reload
  • 5.提供一份页面头部和底部的美化模板,完成后放在网站的根目录下。
  • (1)新建一个header.html
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head><meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  3. <style type="text/css" media="screen">
  4. body,html {background:#fff;font-family: "Lucida Grande",Calibri,Arial;font-size: 13pt;color: #333;background: #f8f8f8;}
  5. tr.e {background:#f4f4f4;}
  6. th,td {padding:0.1em 0.5em;}
  7. th {text-align:left;font-weight:bold;background:#eee;border-bottom:1px solid #aaa;}
  8. #top1 {width:80%; font-size:28px; margin: 0 auto 5px auto;}
  9. #top2 {width:80%; font-size:18px; margin: 0 auto 5px auto;}
  10. #footer {width:80%;margin: 0 auto; padding: 10pt 0;font-size: 10pt;text-align:center;}
  11. #footer a {font-size: 14px; font-weight: normal; text-decoration: underline;}
  12. #list {border:1px solid #aaa;width:80%;margin: 0 auto;padding: 0;}
  13. a {color: #b00;font-size: 11pt;font-weight: bold;text-decoration: none;}
  14. a:hover {color: #000;}
  15. #readme {padding:0;margin:1em 0;border:none;width:100%;}
  16. </style>
  17. <script type="text/javascript">// <!CDATAfunction ngx_onload(){var f=document.getElementById('readme');if(!(f&&f.contentDocument))return;f.style.height=f.contentDocument.body.offsetHeight+'px';f.contentDocument.body.style.padding='0';f.contentDocument.body.style.margin='0';}// ]]></script>
  18. <title>LuckTang下载站</title>
  19. </head>
  20. <body onload="ngx_onload()">
  21. <h1 id="top1">文件目录列表</h1>
  22. <h1 id="top2">Directory listing of
  • (2)新建一个footer.html
  1. <!-- footer START -->
  2. <div id="footer">
  3. <div id="themeinfo">
  4.  <a href="http://www.laifengba.com/1502.html" target="_blank" title="LuckTang Download Center">想拥有这样的一个下载站?</a> | <a href="http://www.laifengba.com" target="_blank">LuckTang博客</a>  | <a href="http://www.laifengba.com/linux/" target="_blank">Linux学习笔记</a> | <a href="http://www.116ss.com" target="_blank">免费SS</a>
  5.  </div>
  6. <div id="copyright">
  7. 本站所有资源均来源于互联网络,仅供学习参考之用,不得用于商业用途 2015-2016 Powered by LuckTang
  8. 由于服务器在国外,即使对其进行了网络优化仍存在不稳定的因素,较大的文件建议使用迅雷等离线下载的方式先下载到离线下载服务器,再自行下载到本地以节约下载时间,中国大陆地区以外的服务器之间传输一般不受影响</div>
  9. </div>
  10. <!-- footer END -->
  • html文件请根据自己的需要修改即可。
本文地址:http://www.laifengba.com/?p=1502
关注我们:请关注一下我们的微信公众号:扫描二维码,公众号:aiboke112
版权声明:本文为原创文章,版权归 wuwenwu 所有,欢迎分享本文,转载请保留出处!

评论已关闭!