全球主机交流论坛

标题: 【一起学FreeBSD】用Ports安装Nginx+FancyIndex漂亮的目录列表程序 [打印本页]

作者: HXS    时间: 2015-10-31 09:40
标题: 【一起学FreeBSD】用Ports安装Nginx+FancyIndex漂亮的目录列表程序
本帖最后由 HXS 于 2015-11-1 09:21 编辑

我也刚接触FreeBSD没几天,也许方法很笨的,高手们看了别见笑!

:D :D :D :D

如果使用源码编译安装,和Linux的安装过程基本类似,
请参考我前次发的一篇Linux上安装的帖子,
这里我们采用Ports的方式安装

第一步,安装更新Ports:

# portsnap fetch&&portsnap extract&&portsnap update

第二步,安装编译nginx

cd /usr/ports/www/nginx
make config   //选择需要的模块,光标移动到HTTP_FANCYINDEX,按空格选中
make fetch    //获取源码包
make extract  //解压缩源码包
按需修改fancyindex插件模板文件/usr/ports/www/nginx/work/ngx-fancyindex-0.3.5/template.h
make           //开始编译nginx
make install  //安装nginx

编辑/etc/rc.conf文件,末尾增加一行
nginx_enable="YES"

启动nginx
service nginx start

重启和停止nginx
service nginx restart
service nginx stop

第三步,配置FancyIndex插件

在/usr/local/etc/nginx/nginx.conf文件中如下位置

  1.         location / {
  2.             root   /usr/local/www/nginx;
  3.             index  index.html index.htm;
  4.         }
复制代码


增加

  1.              fancyindex on;
  2.              fancyindex_exact_size off;
  3.              fancyindex_localtime on;
  4.              fancyindex_footer /footer.html;
  5.              fancyindex_header /header.html;
  6.              fancyindex_ignore footer.html header.html;
复制代码


修改好的应该是这样:

  1.         location / {
  2.             root   /usr/local/www/nginx;
  3.             index  index.html index.htm;
  4.              fancyindex on;
  5.              fancyindex_exact_size off;
  6.              fancyindex_localtime on;
  7.              fancyindex_footer /footer.html;
  8.              fancyindex_header /header.html;
  9.              fancyindex_ignore footer.html header.html;
  10.         }
复制代码


第四步,关于中文目录和文件的支持

1. 修改/usr/local/etc/nginx/nginx.conf
  找到 #charset koi8-r;
  将前面的注释去掉,并修改为charset  utf-8;

2. SFTP软件使用UTF-8编码上传即可。
作者: HXS    时间: 2015-10-31 09:42
如果你需要我下面的这样的FancyIndex的模板,可以用我附件提供的模板

模板演示 http://dd.hxs.biz
作者: yjlml    时间: 2015-10-31 09:43
干嘛要用FreeBSD
作者: 村长    时间: 2015-10-31 09:43
感谢分享,mark
作者: HXS    时间: 2015-10-31 09:44
yjlml 发表于 2015-10-31 09:43
干嘛要用FreeBSD

我也发过CentOS和Debian上安装的FancyIndex帖子
作者: yjlml    时间: 2015-10-31 09:54
HXS 发表于 2015-10-31 09:44
我也发过CentOS和Debian上安装的FancyIndex帖子

马上开折腾机来玩一下
作者: HelloAoA    时间: 2015-10-31 10:14
。。楼主不行呀……你这慢的……已经醉了

(, 下载次数: 0)
作者: hjg    时间: 2015-10-31 10:18
提示: 作者被禁止或删除 内容自动屏蔽
作者: yjlml    时间: 2015-10-31 10:43
折腾了一下   
目录下没有这个文件

第三步,配置FancyIndex插件

在/usr/local/etc/nginx/nginx.conf文件中如下位置
作者: HXS    时间: 2015-10-31 11:55
yjlml 发表于 2015-10-31 10:43
折腾了一下   
目录下没有这个文件

老大你这元老是水上面的吗?比我还水啊~~
作者: 民工三代    时间: 2015-10-31 13:27
其实也不懂FreeBSD

69.12.83.100/tz.php
作者: funders    时间: 2015-10-31 13:54
https://github.com/eigan/Apache-Autoindex-Style  这个更好看
作者: HXS    时间: 2015-10-31 15:16
funders 发表于 2015-10-31 13:54
https://github.com/eigan/Apache-Autoindex-Style  这个更好看

纯静态页面还是nginx好吧
作者: Cokid    时间: 2015-10-31 15:54
干嘛一定 要用FreeBSD
作者: 带头盔滴衰锅    时间: 2015-10-31 16:55
安装我都是直接make install clean,简单方便,一样能选择需要的东西!

话说我也不懂FreeBSD
http://www.lovekk.org/sys
作者: ingress    时间: 2015-10-31 17:09
支持纯技术贴
作者: HXS    时间: 2015-11-1 09:19
带头盔滴衰锅 发表于 2015-10-31 16:55
安装我都是直接make install clean,简单方便,一样能选择需要的东西!

话说我也不懂FreeBSD

先make config后
再执行make BATCH=YES install clean
就可以不会1次又1次的跳出扩展选项的选择框了
作者: 带头盔滴衰锅    时间: 2015-11-1 11:46
HXS 发表于 2015-11-1 09:19
先make config后
再执行make BATCH=YES install clean
就可以不会1次又1次的跳出扩展选项的选择框了 ...

原理是一样的,make config就是配置,而BATCH=YES则是直接确认,也就是之后的所有选项都是默认的




欢迎光临 全球主机交流论坛 (https://loc.mjj8.eu.org/) Powered by Discuz! X3.4