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.example.com/about/">关于我们</a> | <a href="http://www.example.com/sitemap.html">网站导航</a> | <a href="http://www.example.com/sitemap.xml">网站地图</a> |<a rel="nofollow" href="http://www.example.com/">example公司</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;
}
...
作者:wanghongwei
版权声明:本作品遵循<CC BY-NC-ND 4.0>版权协议,商业转载请联系作者获得授权,非商业转载请附上原文出处链接及本声明。
分类:
Nginx
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?