為了簡單共享文件,有些人使用svn,有些人使用ftp,但是更多得人使用索引(index)功能。apache得索引功能強大,并且也是最常見得,nginx的auto_index實現得目錄索引偏少,而且功能非常簡單。先來看看我們得效果圖。
nginx配置
location ~ ^/2589(/.*) { autoindex on; //開啟 autoindex_localtime on;//開啟顯示功能 }
auto_index指令
語法: autoindex on | off;
配置段: autoindex off;
配置段: http, server, location
啟用/僅用nginx目錄索引功能.
語法: autoindex_exact_size on | off;
配置段:autoindex_exact_size on;
配置段: http, server, location
制定是否額外得顯示文件得大小,單位為字節,mb,gb等等. 默認是打開得
syntax: autoindex_localtime on | off;
配置段: autoindex_localtime off;
配置段: http, server, location
指定是否顯示目錄或者文件得時間,默認是不顯示。
nginx+fancy實現漂亮的索引目錄
nginx索引目錄自帶的功能很簡單,而且不好看,如何做一個漂亮的索引列表.接下來看.
安裝環境
系統:centos 6.3nginx:1.4.2
fancy: http://wiki.nginx.org/NgxFancyIndex
下載安裝fancy
對比一下nginx內置的index效果(上篇文章貼過來的圖),如下
# wget http://gitorious.org/ngx-fancyindex/ngx-fancyindex/archive-tarball/master# tar -xzvf master# wget http://nginx.org/download/nginx-1.4.2.tar.gz# tar -xzvf nginx-1.4.2.tar.gz# cd nginx-1.4.2# ./configure --prefix=/usr/local/nginx-1.4.2 --add-module=../ngx-fancyindex-ngx-fancyindex# make# make install
fancy索引配置
server {listen 80; server_name test.Vevb.com; access_log /data/logs/nginx/test.Vevb.com.access.log main;index index.html index.php index.html; root /data/site/test.Vevb.com;location / {} location ~ ^/2589(/.*) { fancyindex on; fancyindex_exact_size off; fancyindex_localtime on; fancyindex_footer "myfooter.shtml"; } }
看看nginx加了fancy的效果,如下圖.
比自帶的好看多少,這個不好說...反正就是....變好看了點~
參數解釋:
fancyindex on:開啟fancy索引
fancyindex_exact_size off:不使用精確的大小,使用四舍五入,1.9M會顯示為2M這樣.如果開啟的話,單位為字節
fancyindex_localtime on:使用本地時間
fancyindex_footer "myfooter.shtml":把當前路徑下的myfooter.shtml內容作為底部.文件不存在底部會出現404
myfooter.shtml內容如下:
<!-- footer START --> <div id="footer"> <a id="gotop" href="#" onclick="MGJS.goTop();return false;">回到頂部</a> <a id="powered" >WordPress</a> <div id="copyright"> 版權所有 © 2006-2015 錯新站長站 </div> <div id="themeinfo"> <a href="http://www.49028c.com/about/">關于我們</a> | <a href="http://www.49028c.com/sitemap.html">網站導航</a> | <a href="http://www.49028c.com/sitemap.xml">網站地圖</a> |<a rel="nofollow" >蘇ICP備14036222號</a> </div> </div> <!-- footer END -->fancy指令使用:
新聞熱點
疑難解答