Nginx 索引目录美化

admin Nginx评论8091字数 2370阅读模式

首先你的网站是这个样子
Nginx 索引目录美化
别人家网站长的比你好看
Nginx 索引目录美化
首先git拉一下ngx-fancyindex的模块

  1. [root@localhost home]# git clone https://github.com/aperezdc/ngx-fancyindex.git  
  2. Cloning into 'ngx-fancyindex'...  
  3. remote: Enumerating objects: 14, done.  
  4. remote: Counting objects: 100% (14/14), done.  
  5. remote: Compressing objects: 100% (12/12), done.  
  6. remote: Total 755 (delta 3), reused 4 (delta 0), pack-reused 741  
  7. Receiving objects: 100% (755/755), 223.81 KiB | 107.00 KiB/s, done.  
  8. Resolving deltas: 100% (429/429), done.  
  9. [root@localhost home]#  

然后么,开始安装nginx

  1. [root@localhost home]# tar xvf nginx-1.10.1.tar.gz  
  2. [root@localhost home]# cd nginx-1.10.1/  
  3. [root@localhost nginx-1.10.1]# ./configure --add-module=../ngx-fancyindex/ --prefix=/usr/local/nginx  --with-http_stub_status_module  --with-http_ssl_module  
  4. [root@localhost nginx-1.10.1]# make && make install  

安装完成后,我们搞套索引主题来

  1. 先随便进个目录,然后git上拉个索引主题  
  2. [root@tmp tmp]# git clone https://github.com/Naereen/Nginx-Fancyindex-Theme.git  
  3. Cloning into 'Nginx-Fancyindex-Theme'...  
  4. remote: Enumerating objects: 182, done.  
  5. remote: Total 182 (delta 0), reused 0 (delta 0), pack-reused 182  
  6. Receiving objects: 100% (182/182), 654.20 KiB | 131.00 KiB/s, done.  
  7. Resolving deltas: 100% (81/81), done.  

下载主题后,我们看到里面有2套,一套黑色,一套白色分别是
Nginx-Fancyindex-Theme-dark
Nginx-Fancyindex-Theme-light

然后将主题拷贝到网站目下

  1. [root@tmp-tmp]# mv Nginx-Fancyindex-Theme/Nginx-Fancyindex-Theme-light /home/  

然后配置下nginx,注意看下配置文件中的索引html指向

  1. [root@localhost conf]# cat nginx.conf  
  2. worker_processes  auto;  
  3.   
  4. events {  
  5.     worker_connections  1024;  
  6. }  
  7.   
  8.   
  9. http {  
  10.     include       mime.types;  
  11.     default_type  application/octet-stream;  
  12.     sendfile        on;  
  13.     keepalive_timeout  65;  
  14.   
  15.     fancyindex on;  
  16.     fancyindex_exact_size off;  
  17.     fancyindex_localtime on;  
  18.     fancyindex_header "/Nginx-Fancyindex-Theme-light/header.html";  
  19.     fancyindex_footer "/Nginx-Fancyindex-Theme-light/footer.html";  
  20.     fancyindex_ignore "examplefile.html";  
  21.     fancyindex_ignore "Nginx-Fancyindex-Theme-light";  
  22.     fancyindex_name_length 255;  
  23.   
  24.   
  25.     server {  
  26.         listen       80;  
  27.         server_name  localhost;  
  28.   
  29.         location / {  
  30.             root   /home/;  
  31.             index  index.html index.htm;  
  32.         }  
  33.   
  34.   
  35.         error_page   500 502 503 504  /50x.html;  
  36.         location = /50x.html {  
  37.             root   html;  
  38.         }  
  39.     }  
  40. }  

配置完成后,启动nginx

注意:重启需要先停止,再启动方可生效!!!

更多相关文章

nginx配置目录访问&用户名密码控制

版权声明:文章图片资源来源于网络,如有侵权,请留言删除!!!
admin
  • 本文由 发表于 2021年9月24日 20:14:09
  • 转载请务必保留本文链接:https://www.58pxe.com/7649.html
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: