由于fdfs是应用的fdfs协议,当用web访问时,需要提供http协议的接口,所以要在storage节点上编译安装nginx

git clone https://github.com/happyfish100/fastdfs-nginx-module.gittar xf nginx-1.8.0.tar.gzcd nginx-1.8.0yum install -y pcreyum install -y pcre-devel./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx  --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --add-module=../fastdfs-nginx-module/srcmake && make installgroupadd -r nginxuseradd -g nginx -r nginx

nginx编译安装完毕

设置fastdfs-nginx-module:

ln -sv /data/fdfs/storage/data/ /data/fdfs/storage/data/M00

靠谱模块的配置文件:

 cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

编写配置文件:

[root@node2 ~]# cat /etc/fdfs/mod_fastdfs.confconnect_timeout=2network_timeout=30base_path=/data/fdfs/storageload_fdfs_parameters_from_tracker=truestorage_sync_file_max_delay = 86400use_storage_id = falsestorage_ids_filename = storage_ids.conftracker_server=192.168.145.93:22122        //此处为tracker的地址和端口storage_server_port=23000group_name=group1url_have_group_name = true                //默认为false,要改为truestore_path_count=1store_path0=/data/fdfa/storagelog_level=infolog_filename=response_mode=proxyif_alias_prefix=flv_support = trueflv_extension = flvgroup_count = 1                        //启用存储节点,有几个配置几个[group1]                                //节点相关信息配置group_name=group1storage_server_port=23000store_path_count=1store_path0=/data/fdfs/storage

之前使用rpm包的方式安装的fdfs,所以需要拷贝配置文件到/etc/fdfs

cp /root/fastdfs-5.0.11/conf/http.conf /etc/fdfs/cp /root/fastdfs-5.0.11/conf/mime.types /etc/fdfs/

配置nginx.conf,添加location

 location ~ /group[0-9]+/M00/ {    root /data/fdfs/storage/data/;    ngx_fastdfs_module;  }

重启fdfs的存储节点,并启动nginx

service fdfs_storaged restart/usr/local/ngins/sbin/nginx

上传图片并测试

fdfs_upload_file /etc/fdfs/storage.conf /tmp/a.jpg存储信息:group1/M00/00/00/wKiRXVi-rhOAWDyBAAJOvgO1aMA061.jpg

通过web访问成功