【FastDFS】Nginx集成FastDFS

Nginx配置安装

  • 下载fastdfs-nginx-module(不建议使用github上,因为编译有问题)

  • 由于github上下载来的安装包文件在安装时或多或少会出现bug,此处建议使用小编给大家处理过的安装包进行安装,以下所有安装包获取方式:

    百度网盘:
    链接:https://pan.baidu.com/s/1rnwVzlJDA0ykxBzbSOsDWQ
    提取码:thmn

    蓝奏云:
    https://wws.lanzous.com/b01huf3ah
    密码:thmn

# 解压文件
[root@CentOSX ~]# tar -zxf fastdfs-nginx-module.tar.gz
# 安装所需组件包
[root@CentOSX ~]# yum install -y pcre-devel
[root@CentOSX ~]# yum install -y openssl-devel
# 使用wget下载Nginx
[root@CentOSX ~]# wget http://nginx.org/download/nginx-1.11.1.tar.gz
# 解压Nginx
[root@CentOSX ~]# tar -zxf nginx-1.11.1.tar.gz
# 将/root/fastdfs-nginx-module/src追加至Nginx
[root@CentOSX nginx-1.11.1]# ./configure --prefix=/usr/local/nginx-1.11.1/ --add-module=/root/fastdfs-nginx-module/src
# 编译安装
[root@CentOSX nginx-1.11.1]# make 
[root@CentOSX nginx-1.11.1]# make install

拷贝配置

[root@CentOSX ~]# cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@CentOSX ~]# cd fastdfs-5.11/conf/
[root@CentOSX conf]# cp http.conf mime.types anti-steal.jpg /etc/fdfs/

配置nginx.conf

/usr/local/nginx-1.11.1/conf/nginx.conf加入如下配置

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

修改mod_fastdfs.conf

[root@CentOSX ~]# vi /etc/fdfs/mod_fastdfs.conf
tracker_server=CentOSA:22122
tracker_server=CentOSB:22122
tracker_server=CentOSC:22122

url_have_group_name = true
group_name=group[1,2,3]
store_path_count=2

store_path0=/data/fdfs/storage/store01
store_path1=/data/fdfs/storage/store02

启动nginx

[root@CentOSX ~]# cd /usr/local/nginx-1.11.1/
[root@CentOSX nginx-1.11.1]# ./sbin/nginx -t
ngx_http_fastdfs_set pid=116305
ngx_http_fastdfs_set pid=116305
nginx: the configuration file /usr/local/nginx-1.11.1//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.11.1//conf/nginx.conf test is successful

测试下载

[root@CentOSA ~]# fdfs_upload_file /etc/fdfs/client.conf install.log
group2/M01/00/00/wKikgl0p_4-AIqGJAAAixZ60QfI693.log

在本地浏览器中任意访问一个nginx服务查看效果

http://192.168.164.129/group2/M01/00/00/wKikgl0p_4-AIqGJAAAixZ60QfI693.log?filename=install.log
http://192.168.164.131/group2/M01/00/00/wKikgl0p_4-AIqGJAAAixZ60QfI693.log

图片和文字文件会在网页上展示出来,PDF等文件会弹窗提示下载

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ubTvUFIM-1606631131934)(C:\Users\lenovo\AppData\Roaming\Typora\typora-user-images\image-20201110211941216.png)]

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@是小白吖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值