免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 9879 | 回复: 4
打印 上一主题 下一主题

[FastDFS] FastDFS_v4.06+nginx-1.4.2配置详解 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-10-09 20:06 |只看该作者 |正序浏览
      这几天在玩FastDFS,在惊叹余大之牛的同时也由衷地感谢鱼大的共享。针对Nginx+FastDFS的配置,做了些简单记录,希望能对后面了解这方面的朋友有所帮助。也希望余大及其他对这块有研究的朋友多多指正。
      具体步骤如下:
1、安装FastDFS(我装的是最新的版本FastDFS_v4.06),具体安装步骤这里就不重复了。

2、安装Nginx(我装的版本是:nginx-1.4.2),可直接以root用户按默认安装,我是非root用户指定目录编译安装:
   1)下载nginx安装包及依赖包(nginx-1.4.2.tar.gz、pcre-8.33.tar.gz、zlib-1.2.8.tar.gz)
   2)分别解压:
      # tar zxvf nginx-1.4.2.tar.gz
      # tar zxvf pcre-8.33.tar.gz
      # tar zxvf zlib-1.2.8.tar.gz
   3)编译安装
      # cd nginx-1.4.2
      #./configure --prefix=/webapp/nginx --with-pcre=/webapp/tools/pcre-8.33 --with-zlib=/webapp/tools/zlib-1.2.8
      # make
      # make install
   4)修改nginx.conf配置文件,启动nginx验证是否安装成功

3、Nginx添加模块
   1)下载安装包(我用的是fastdfs-nginx-module_v1.15)
   2)解压:tar xzf fastdfs-nginx-module_v1.15.tar.gz
   3)编译安装(Nginx的安装源目录,即nginx-1.4.2解压目录):
   # ./configure --prefix=/webapp/nginx --add-module=/webapp/tools/fastdfs-nginx-module/src --with-pcre=/webapp/tools/pcre-8.33 --with-zlib=/webapp/tools/zlib-1.2.8
   # make
   # make install
   说明:如果需要修改mod_fastdfs.conf文件的路径,需要在安装之前修改conf配置文件中的:-DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"

4、修改配置文件
   1)nginx.conf
     在server中增加配置:
     访问路径不带group名(storage只有一个group的情况),如/M00/00/00/xxx:
      location /M00 {
            ngx_fastdfs_module;
        }
     访问路径带group名(storage对应有多个group的情况),如/group1/M00/00/00/xxx:
      location ~ /group([0-9])/M00 {
            ngx_fastdfs_module;
        }
   2)mod_fastdfs.conf
        将fastdfs-nginx-module_v1.15解压目录fastdfs-nginx-module/src下的mod_fastdfs.conf复制到-DFDFS_MOD_CONF_FILENAME配置的目录下,如/etc/fdfs/。
    修改配置:
    tracker_server=192.168.1.241:22122        -- tracker server的ip和端口,此处可以写多个tracker server,每行一个
    url_have_group_name = true              --访问路径带group时为true否则为false,多个group的情况下,必须为true,为false时,group_count必须为0

storage只有一个group的情况:
   group=group1                           --storage对应的group
   store_path0=/webapp/fastdfs/storage        --storage存储路径
   group_count = 0

storage对应有多个group的情况:
   url_have_group_name = true      --必须设置为true才能支持多个group
   group_count = 2                 --storage的group个数

   [group1]
   group_name=group1
   storage_server_port=23000
   store_path_count=1
   store_path0=/webapp/fastdfs/storage
   
   [group2]
   group_name=group2
   storage_server_port=23000
   store_path_count=1
   store_path0=/webapp/fastdfs/storage2

5、重启Nginx,验证。

论坛徽章:
1
寅虎
日期:2014-03-17 10:18:07
5 [报告]
发表于 2014-03-24 14:21 |只看该作者
本帖最后由 xjacks 于 2014-03-24 14:22 编辑

谢谢楼主的帖子,帮了我很大的忙~
多group的时候设置location时后边是~号,我一开始没细看,漏了这个,结果怎么都访问不成功,后来才发现原来是~号作怪

   1)nginx.conf
     在server中增加配置:
     访问路径不带group名(storage只有一个group的情况),如/M00/00/00/xxx:
      location /M00 {
            ngx_fastdfs_module;
        }
     访问路径带group名(storage对应有多个group的情况),如/group1/M00/00/00/xxx:
      location ~/group([0-9])/M00 {
            ngx_fastdfs_module;
        }

论坛徽章:
0
4 [报告]
发表于 2013-12-13 09:15 |只看该作者
回复 1# lcz_3





storage对应有多个group的情况,这种情况的配置,即以下这几行配置,请问你是添加到mod_fastdfs.conf里了么?
  [group1]
   group_name=group1
   storage_server_port=23000
   store_path_count=1
   store_path0=/webapp/fastdfs/storage
   
   [group2]
   group_name=group2
   storage_server_port=23000
   store_path_count=1
   store_path0=/webapp/fastdfs/storage2
   

论坛徽章:
0
3 [报告]
发表于 2013-10-11 15:07 |只看该作者
真的够详细了。。感谢!!

论坛徽章:
1
处女座
日期:2014-01-21 13:20:51
2 [报告]
发表于 2013-10-09 20:18 |只看该作者

I 帮顶,I 路过
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP