Nginx文件服务器 – FancyIndex插件美化教程

1.下载FancyIndex包:https://codeload.github.com/aperezdc/ngx-fancyindex/zip/master
2.将下载的zip包解压到nginx源码目录

unzip ngx-fancyindex-master.zip

3.编辑安装Nginx

yum -y install gcc-c++
yum -y install pcre-devel zlib-devel openssl-devel
./configure --prefix=/usr/local/nginx --add-module=./ngx-fancyindex-master
make
make install

4.下载fancyindex资源文件:https://github.com/TheInsomniac/Nginx-Fancyindex-Theme
5.下载后,解压到站点根目录

unzip Nginx-Fancyindex-Theme-master.zip
mv Nginx-Fancyindex-Theme-master fancyindex

6.配置Nginx配置文件,在location或者server中添加以下代码:

#autoindex on;
#autoindex_exact_size off;
#autoindex_localtime on;
fancyindex on;
fancyindex_localtime on; #on for local time zone. off for GMT
fancyindex_exact_size off; #off for human-readable. on for exact size in bytes
fancyindex_header "/fancyindex/header.html";
fancyindex_footer "/fancyindex/footer.html";
fancyindex_ignore "fancyindex"; #ignore this directory when showing list
fancyindex_default_sort date_desc; #以上传时间倒序排列

7.启动nginx

/usr/local/nginx/sbin/nginx -s stop && /usr/local/nginx/sbin/nginx

8.自定义footer.html信息(可选)

<!-- footer START -->
<div id="footer">
<a id="gotop" href="#" onclick="MGJS.goTop();return false;">回到顶部</a>
<a id="powered" href="http://wordpress.org/">WordPress</a>
<div id="copyright">
版权所有 © 本页面由xxx提供 </div>
<div id="themeinfo">
<a href="http://www.xxx.com/about/">关于我们</a> | <a href="http://www.xxx.com/sitemap.html">网站导航</a> | <a href="http://www.xxx.com/sitemap.xml">网站地图</a> |<a rel="nofollow" href="http://www.xxx.com/">xxx公司</a>
</div>
</div>
<!-- footer END -->

9.使用php动态页面的nginx配置(可选)

root /share;
index index.php;
location / {
charset utf-8;
#autoindex on;
#autoindex_exact_size off;
#autoindex_localtime on;
fancyindex on;
fancyindex_localtime on;
fancyindex_exact_size off;
fancyindex_header "/fancyindex/header.php";
fancyindex_footer "/fancyindex/footer.php";
# fancyindex_ignore "fancyindex";
# fancyindex_default_sort date_desc;
index index.php index.html index.htm;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


location /favicon.ico {
log_not_found off;
access_log off;
}

原文链接: https://www.cnblogs.com/wang-hongwei/p/14558436.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Nginx文件服务器 - FancyIndex插件美化教程

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/208967

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午11:39
下一篇 2023年2月12日 下午11:39

相关推荐