為了簡(jiǎn)單共享文件,有些人使用svn,有些人使用ftp,但是更多得人使用索引(index)功能。apache得索引功能強(qiáng)大,并且也是最常見(jiàn)得,nginx的auto_index實(shí)現(xiàn)得目錄索引偏少,而且功能非常簡(jiǎn)單。先來(lái)看看我們得效果圖。

nginx配置
location ~ ^/2589(/.*) { autoindex on; //開(kāi)啟 autoindex_localtime on;//開(kāi)啟顯示功能 }auto_index指令
語(yǔ)法: autoindex on | off;
配置段: autoindex off;
配置段: http, server, location
啟用/僅用nginx目錄索引功能.
語(yǔ)法: autoindex_exact_size on | off;
配置段:autoindex_exact_size on;
配置段: http, server, location
制定是否額外得顯示文件得大小,單位為字節(jié),mb,gb等等. 默認(rèn)是打開(kāi)得
syntax: autoindex_localtime on | off;
配置段: autoindex_localtime off;
配置段: http, server, location
指定是否顯示目錄或者文件得時(shí)間,默認(rèn)是不顯示。
nginx+fancy實(shí)現(xiàn)漂亮的索引目錄
nginx索引目錄自帶的功能很簡(jiǎn)單,而且不好看,如何做一個(gè)漂亮的索引列表.接下來(lái)看.
安裝環(huán)境
系統(tǒng):centos 6.3nginx:1.4.2
fancy: http://wiki.nginx.org/NgxFancyIndex
下載安裝fancy
對(duì)比一下nginx內(nèi)置的index效果(上篇文章貼過(guò)來(lái)的圖),如下
# 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的效果,如下圖.

比自帶的好看多少,這個(gè)不好說(shuō)...反正就是....變好看了點(diǎn)~
參數(shù)解釋:
fancyindex on:開(kāi)啟fancy索引
fancyindex_exact_size off:不使用精確的大小,使用四舍五入,1.9M會(huì)顯示為2M這樣.如果開(kāi)啟的話,單位為字節(jié)
fancyindex_localtime on:使用本地時(shí)間
fancyindex_footer "myfooter.shtml":把當(dāng)前路徑下的myfooter.shtml內(nèi)容作為底部.文件不存在底部會(huì)出現(xiàn)404
myfooter.shtml內(nèi)容如下:
<!-- footer START --> <div id="footer"> <a id="gotop" href="#" onclick="MGJS.goTop();return false;">回到頂部</a> <a id="powered" >WordPress</a> <div id="copyright"> 版權(quán)所有 © 2006-2015 錯(cuò)新站長(zhǎng)站 </div> <div id="themeinfo"> <a href="http://m.survivalescaperooms.com/about/">關(guān)于我們</a> | <a href="http://m.survivalescaperooms.com/sitemap.html">網(wǎng)站導(dǎo)航</a> | <a href="http://m.survivalescaperooms.com/sitemap.xml">網(wǎng)站地圖</a> |<a rel="nofollow" >蘇ICP備14036222號(hào)</a> </div> </div> <!-- footer END -->fancy指令使用:
新聞熱點(diǎn)
疑難解答
圖片精選