FastDFS----使用Nginx提供服务

首先需要安装Nginx

1、下载 Nginx

nginx-1.10.0.tar.gz
下载
fastdfs-nginx-module:https://github.com/happyfish100/fastdfs-nginx-module
fastdfs-nginx-module-master

2、编译

./configure --prefix=/usr/local/nginx --with-pcre --add-module=/home/lot/project/fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1/src

3、安装

make && make install
可能会出现以下问题

	-o objs/src/http/modules/ngx_http_upstream_zone_module.o \
	src/http/modules/ngx_http_upstream_zone_module.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='"/etc/fdfs/mod_fastdfs.conf"'  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules -I /usr/include/fastdfs -I /usr/include/fastcommon/ \
		-o objs/addon/src/ngx_http_fastdfs_module.o \
		/home/lot/project/fastdfs-nginx-module-master/src/ngx_http_fastdfs_module.c
In file included from /home/lot/project/fastdfs-nginx-module-master/src/ngx_http_fastdfs_module.c:6:0:
/home/lot/project/fastdfs-nginx-module-master/src/common.c: In function ‘fdfs_http_request_handler’:
/home/lot/project/fastdfs-nginx-module-master/src/common.c:1245:61: error: ‘FDFSHTTPParams’ has no member named ‘support_multi_range’
                 (pContext->range_count > 1 && !g_http_params.support_multi_range))
                                                             ^
make[1]: *** [objs/addon/src/ngx_http_fastdfs_module.o] Error 1
make[1]: Leaving directory `/home/lot/project/nginx-1.10.0'
make: *** [build] Error 2

在这里插入图片描述
解决方法
https://blog.csdn.net/hohoo1990/article/details/51444793

修改配置

1、创建软连接

创建一个软连接,在/fastdfs/storage文件存储目录下创建软连接,将其链接到实际存放数据的目录
示例:ln -s /home/fastdfs/storage/data/ /home/fastdfs/storage/data/M00

2、修改Nginx配置文件

vi /mnt/FastDFS/conf/fdfs_nginx.conf
server {
listen 80;
server_name localhost;

    location ~ /group[0-9]/M00 {
        ngx_fastdfs_module;
    }

}

3、修改mod文件

命令:vi /etc/fdfs/mod_fastdfs.conf
修改内容:比如连接超时时间、跟踪器路径配置、url的group配置
connect_timeout=10
tracker_server=IP:22122
url_have_group_name = true
store_path0=/home/yuqing/fastdfs/storage

4、重启Nginx

查看 nginx 及 子进程 ps -aux|grep nginx
重启 /mnt/FastDFS/nginx/nginx-1.10.3/objs/nginx -c /mnt/FastDFS/conf/fdfs_nginx.conf

测试访问

1、上传文件

在这里插入图片描述

2、文件预览

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

不太灵光的程序员

有用的话可以请博主喝杯咖啡续命

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

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

打赏作者

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

抵扣说明:

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

余额充值