首先需要安装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