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