由于余老师在 V4.05 以后的版本就把内置 HTTP服务去掉了,所以就算这篇你测试上传成功了,你也访问不了。
推荐大家结合 Nginx 使用 fastdfs-nginx-module 模块,

搭建好fastdfs 系统后 就可以搭建web访问功能了。

大体思路有以下两种
1.直接安装nginx关于fastdfs集合的扩展模块  fastdfs-nginx-module  
    或者直接安装apache关于fastdfs集合的扩展模块  fastdfs-apache-module  
   fastdfs-nginx-module 的作用:
       在每一台storage上部署Nginx及 fastdfs-nginx-module扩展模块,如果当前storage节点找不到文件时
会向源storage主机发起redirect或proxy动作
 
2.安装web软件后,通过配置nginx实现了fastdfs-nginx-module的功能
第一种(推荐).
下载nginx  和   插件fastdfs-nginx-module-master.zip   这两个软件
(如果nginx已经安装好了,需要重新编译一遍,编译时把插件装上)
(如果nginx使用yum安装的,需要下载yum相同版本安装包,重新编译)
这里从头开始安装:
解压:
# tar -zxvf nginx-1.13.5.tar.gz
# unzip fastdfs-nginx-module-master.zip 
安装nginx和fastdfs插件:
 ./configure --prefix=/usr/local/nginx  --add-module=/home/packages/fastdfs-nginx-module-master/src
连续报错:
报错: the HTTP rewrite module requires the PCRE library.……
解决:yum install pcre-devel.x86_64
报错: the HTTP gzip module requires the zlib library.……
解决:yum install zlib-devel.x86_64

编译成功:

adding module in /home/packages/fastdfs-nginx-module-master/src
 + ngx_http_fastdfs_module was configured

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
继续安装:
# make
# make install
进入nginx安装目录,修改其配置文件:
# cd /usr/local/nginx/conf
# vi nginx.conf
增加以下内容:

 location /M00 {
            root /home/yuqing/fastdfs/data;
            ngx_fastdfs_module;
        }
新建一个软连接:
# ln -s /home/yuqing/fastdfs/data  /home/yuqing/fastdfs/data/M00
复制并修改mod_fastdfs.conf文件:
# cp mod_fastdfs.conf /etc/fdfs/
# vi /etc/fdfs/mod_fastdfs.conf
修改了这里:
tracker_server=10.0.0.42:22122
(复制这两个文件到fdfs配置文件,要不无法访问nginx)
(# cp /home/fastdfs-5.11/conf/http.conf /etc/fdfs/)
(# cp /home/fastdfs-5.11/conf/mime.types /etc/fdfs/)
重启nginx:
# /usr/local/nginx/sbin/nginx -s stop;
# /usr/local/nginx/sbin/nginx
报错:浏览器无法访问
查看nginx错误日志 如下
 ERROR - file: ini_file_reader.c, line: 631, include file "http.conf" not exists, line: "#include http.conf"
 ERROR - file: /home/packages/fastdfs-nginx-module-master/src/common.c, line: 163, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
解决:# cp /home/fastdfs-5.11/conf/http.conf /etc/fdfs/
 ERROR - file: shared_func.c, line: 968, file /etc/fdfs/mime.types not exist
解决:# cp /home/fastdfs-5.11/conf/mime.types /etc/fdfs/
访问nginx 成功
下面看一下 mod_fastdfs.conf文件:
# connect timeout in seconds
# default value is 30s
connect_timeout=2
连接超时时间
# network recv and send timeout in seconds
# default value is 30s
network_timeout=30
发送接受数据 超时时间
# the base path to store log files
base_path=/tmp
日志文件 位置
# if load FastDFS parameters from tracker server
# since V1.12
# default value is false
load_fdfs_parameters_from_tracker=true
是否从 tracket服务器读取信息
如果不从tracket服务器读取信息,以下三个参数生效
# storage sync file max delay seconds
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.12
# default value is 86400 seconds (one day)
storage_sync_file_max_delay = 86400
      当load_fdfs_parameters_from_tracker设置为false时,本参数生效
同步文件最大延迟时间,与tracker.conf文件中参数相同
默认是一天
# if use storage ID instead of IP address
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# default value is false
# since V1.13
use_storage_id = false
    是否使用storage_id 
# specify storage ids filename, can use relative or absolute path
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.13
storage_ids_filename = storage_ids.conf
     storage_id的位置
# FastDFS tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=10.0.0.42:22122
从tracket服务器读取信息,这个参数生效
tracket服务器地址、端口
# the port of the local storage server
# the default value is 23000
storage_server_port=23000
    本storage server监听端口
# the group name of the local storage server
group_name=group1
      group组名
# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
url_have_group_name = false
url链接中是否包含 组名
类似 /M00/00/00/xxx 和group1/M00/00/00/xxx
如果选择true 即包含组名,需要修改nginx配置文件
将  location /M00    改为     location /group1/M00 
# path(disk or mount point) count, default value is 1
# must same as storage.conf
store_path_count=1
      存储路径数量,必须和 storage.conf文件一致
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/home/yuqing/fastdfs
#store_path1=/home/yuqing/fastdfs1
     存储路径地址、必须和 storage.conf文件一致
# standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info
    日志级别
# set the log filename, such as /usr/local/apache2/logs/mod_fastdfs.log
# empty for output to stderr (apache and nginx error_log file)
log_filename=
     设置日志的名称,为空则记录到 http服务的错误日志里
# response mode when the file not exist in the local file system
## proxy: get the content from other storage server, then send to client
## redirect: redirect to the original storage server (HTTP Header is Location)
response_mode=proxy
当文件在本地不存在时怎样回应

  • proxy 代理,从其它存储服务器获取内容,然后发送给客户
  • redirect  重定向原始存储服务器的http头
# the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
# multi aliases split by comma. empty value means auto set by OS type
# this paramter used to get all ip address of the local host
# default values is empty
if_alias_prefix=
????
多种别名用逗号分隔,空值表示自动设置系统类型
这个参数用于得到本机的所有ip
# use "#include" directive to include HTTP config file
# NOTE: #include is an include directive, do NOT remove the # before include
#include http.conf
   使用#include指令 包含http配置文件
    注意:#include  这是一个包含指令,不要删除 include前面的 #
# if support flv
# default value is false
# since v1.15
flv_support = true
   是否支持flv文件,默认不支持
# flv file extension name
# default value is flv
# since v1.15
flv_extension = flv
    flv文件的扩展名,默认是flv
# set the group count
# set to none zero to support multi-group on this storage server
# set to 0  for single group only
# groups settings section as [group1], [group2], ..., [groupN]
# default value is 0
# since v1.14
group_count = 0
设置组的数量
设置没有0 ,支持多个group组在这个存储服务器上
设置0 为只有一个组
如果服务器上多个组,组的设置 就像这样 [group1], [group2], ..., [groupN]
默认是0,一组
# group settings for group #1
# since v1.14
# when support multi-group on this storage server, uncomment following section
#[group1]
#group_name=group1
#storage_server_port=23000
#store_path_count=2
#store_path0=/home/yuqing/fastdfs
#store_path1=/home/yuqing/fastdfs1
   组1的设置
   若本存储服务器支持多组,取消下面的注释
# group settings for group #2
# since v1.14
# when support multi-group, uncomment following section as neccessary
#[group2]
#group_name=group2
#storage_server_port=23000
#store_path_count=1
#store_path0=/home/yuqing/fastdfs
组2的设置
若本存储服务器支持多组,取消下面的注释
二、直接使用 web访问
这个比较简单,只需要把web根目录指定到 fastdfs的存储目录就可以了
三、web访问fastdfs 的几种思路

3.1  只使用 组名
适用于图片量大、group组多、每个group组都有备份
访问地址类似于   picture.xxx.com/groupx/M00/……jpg
只需要一个域名;
上传图片后 将返回的值 直接+域名  保存为图片名 :picture.xxx.com/groupx/M00/……jpg
前端使用一个nginx做反向代理+负载均衡  配置如下:
upstream group1{
   server group1_storage1:80;
   server group1_storage2:80;
}
upstream group2{
   server group2_storage1:80;
   server group2_storage2:80;
}

location /group1/M00{
proxy_pass http://group1;
}
location /group2/M00{
proxy_pass http://group2;
}

注意:group1 和 group2 中 机器要正确配置 nginx.conf  storage.conf 和 mod_fastdfs.conf 文件

nginx.conf中

 location /group1/M00 {
            root /home/yuqing/fastdfs/data;
            ngx_fastdfs_module;
        }
 特别注意  mod_fastdfs.conf文件中  这两项 组名、url是否包含group名
group_name=
url_have_group_name =
3.2 只使用 域名 (已部署生产环境)
适用于图片较少,每个group组都是单机跑,没有备份的情况
访问地址类似于   picturex.xxx.com/M00/……jpg
需要多个域名;
上传图片后 将返回的值分开后 结合域名 生成图片名   picturex.xxx.com/M00/……jpg
前端使用一个nginx做反向代理  配置如下:
upstream group1{
   server group1_storage1:80;
}
upstream group2{
   server group2_storage1:80;
}

location /group1/M00{
proxy_pass http://group1;
}
location /group2/M00{
proxy_pass http://group2;
}

注意:group1 和 group2 中 机器要正确配置 nginx.conf  storage.conf

由于每组没有备份, mod_fastdfs.conf 也不用安装了
nginx.conf中

 location /group1/M00 {
            root /home/yuqing/fastdfs/data;
        }
3.3 域名和组名同时使用  
适用于图片量大、业务量多、group组多、每个group组都有备份
访问地址类似于   picturex.xxx.com/groupx/M00/……jpg
只需要一个域名;
上传图片后 将返回的值+改动域名  保存为图片名 :picturex.xxx.com/groupx/M00/……jpg
使用多个域名对应一个nginx  做反向代理+负载均衡  配置如下:

upstream group1{
   server group1_storage1:80;
   server group1_storage2:80;
}
upstream group2{
   server group2_storage1:80;
   server group2_storage2:80;
}

server {
        listen       80;
        server_name  picture1.xxx.com;
       ……

location /group1/M00{
proxy_pass http://group1;
}
location /group2/M00{
proxy_pass http://group2;
}
}
server {
        listen       80;
        server_name  picture2.xxx.com;
       ……
}

注意:group1 和 group2 中 机器要正确配置 nginx.conf  storage.conf 和 mod_fastdfs.conf 文件

nginx.conf中

 location /group1/M00 {
            root /home/yuqing/fastdfs/data;
            ngx_fastdfs_module;
        }
 特别注意  mod_fastdfs.conf文件中  这两项 组名、url是否包含group名
group_name=
url_have_group_name =

web访问 FastDFS 方法思路的更多相关文章

  1. Web开发基本准则-55实录-Web访问安全

    Web开发工程师请阅读下面的前端开发准则,这是第一部分,强调了过去几年里我们注意到的Web工程师务须处理的Web访问安全基础点.尤其是一些从传统软件开发转入互联网开发的工程师,请仔细阅读,不要因为忽视 ...

  2. 机器数据的价值 - Web 访问日志和数据库审计日志

    计算机数据 大量的数据流,不断增长的来源,蕴含着巨大的价值 在 Splunk,我们大量谈及计算机数据.这些数据是指在数据中心.“物联网”和互联设备世界中运行的所有系统产生的数据.其中包括支撑组织的应用 ...

  3. IIS6.0服务器搭建网站无法访问解决方法

    IIS6.0服务器搭建网站无法访问解决方法     IIS6.0服务器搭建网站无法访问解决方法很多朋友在用IIS6架网站的时候遇到不少问题,而这些问题有些在过去的IIS5里面就遇到过,有些是新出来的, ...

  4. 此项目的默认Web访问模式设置为文件共享, 但是无法从路径(此为转贴)

    故障现象: 当你打开ASP.NET Web项目时,如果出现这样的错误提示:提示窗口标题: Web访问失败提示内容: 此项目的默认Web访问模式设置为文件共享, 但是无法从路径“...”打开“...”处 ...

  5. OSX 10.8+下开启Web 共享 的方法

    MENU Home Archives About SUBSCRIBE ☰MENU OSX 10.8+ Mountain Lion 下开启 Web Sharing(Web 共享)的方法 JUL 28, ...

  6. OSX 10.8+下开启Web 共享 的方法

    MENU Home Archives About SUBSCRIBE ☰MENU OSX 10.8+ Mountain Lion 下开启 Web Sharing(Web 共享)的方法 JUL 28, ...

  7. 什么是Servlet(原理,从访问到方法)

    Servlet简介 Servlet是SUN公司提供的一门用于开发动态WEB资源的技术.SUN公司在其API中提供了一个Servlet接口,用户若想开发一个动态WEB资源(即开发一个Java程序向浏览器 ...

  8. Java Web工程搭建方法

    搭建一个简单的Web工程主要是以下几步: 一.下载所需工具 ①java   ②eclipse  ③tomcat 注意:java与eclipse版本不匹配(32位或者64位),会导致eclipse启动时 ...

  9. AngularJS使用OData请求ASP.NET Web API资源的思路

    本篇整理AngularJS使用OData请求ASP.NET Web API资源的思路. 首先给ASP.NET Web API插上OData的翅膀,通过NuGet安装OData. 然后,给control ...

随机推荐

  1. P1850 换教室 期望dp

    P1850 换教室 题目描述 对于刚上大学的牛牛来说,他面临的第一个问题是如何根据实际情况申请合适的课程. 在可以选择的课程中,有 2n2n 节课程安排在 nn 个时间段上.在第 ii(1 \leq ...

  2. Vue 组件 传值

    注意 Vue模板只能有一个对象,要想用多个对象时用div包裹 一.父组件->子组件 通过props 1.子组件: 声明:proprs =[‘xx’],xx是在父组件中引用子组件,子组件的属性(t ...

  3. [bzoj1041] [洛谷P2508] [HAOI2008] 圆上的整点

    Description 求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数. Input 只有一个正整数n,n<=2000 000 000 Output 整点个数 Samp ...

  4. java.sql.Date与java.sql.Date区别

    public static void main(String[] args) { java.sql.Date createTime = new java.sql.Date(System.current ...

  5. export 和 export default 的区别

    export命令用于规定模块的对外接口. 一个模块就是一个独立的文件.该文件内部的所有变量,外部无法获取.如果你希望外部能够读取模块内部的某个变量,就必须使用export关键字输出该变量.下面是一个 ...

  6. airtest启用本地python环境的方法

    实现目标,air如果想引用第三方python库,则需要在本地python欢迎执行运行 1.打开设置,红色箭头处,选择本地python路径 2.安装air的两个核心库airtest和pocoui 安装方 ...

  7. C语言寒假大作战01

    问题 回答 这个作业属于哪个课程 2019软件四班C语言寒假作业大作战 这个作业要求在哪里 作业要求 我在这个课程的目标是 gitee 与 git基础命令学习与使用 这个作业在那个具体方面帮助我实现目 ...

  8. 分享一下我在mysql5.6+mysql8数据库安装过程中的一些坑!

    Mysql5.6安装 下载好安装包后,在bin目录下用cmd打开,输入mysqld install [服务名]新建个服务 在windows+r输入services.msc即可查看服务 怎样使用mysq ...

  9. Spring注解开发系列Ⅵ --- AOP&事务

    注解开发 --- AOP AOP称为面向切面编程,在程序开发中主要用来解决一些系统层面上的问题,比如日志,事务,权限等待,Struts2的拦截器设计就是基于AOP的思想,横向重复,纵向抽取.详细的AO ...

  10. MySQL5.7 中的query_cache_size

    摘自:http://jackyrong.iteye.com/blog/2173523 1 原理    MySQL查询缓存保存查询返回的完整结果.当查询命中该缓存,会立刻返回结果,跳过了解析,优化和执行 ...