# cp -r /usr/local/src/fastdfs-master/conf/* /etc/fdfs/
配置tracker配置文件
# cd /etc/fdfs/ && vim tracker.conf
bind_addr=192.168.199.160 # 绑定tracker的地址,tracker和storage为同一台服务器
port=22122 # 端口
base_path=/data/server/fastdfs
store_lookup=0 # 0为轮巡
store_group=group1 # 该服务器为group1
store_server=0 # 0为轮巡
use_storage_id = true # 这里使用组id而不是ip地址
id_type_in_filename = id
# vim /etc/fdfs/storage.conf
group_name=group1
bind_addr=192.168.199.160
port=23000
base_path=/data/server/fastdfs_storage
store_path0=/data/server/fastdfs_storage
tracker_server=192.168.199.160:22122
# vim /etc/fdfs/client.conf
base_path=/data/server/fastdfs_client
tracker_server=192.168.199.160:22122
use_storage_id = ture
创建相关目录
# mkdir /data/server/fastdfs
# mkdir /data/server/fastdfs_storage
# mkdir /data/server/fastdfs_client
# mkdir /data/server/fastdfs_tracker
启动tracker
# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
启动storage
# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
创建相关目录:mkdir /data/server/nginx
5.1、解压fastdfs_nginx_module,然后编译安装nginx,加上此模块一起编译
# cd /usr/local/src/
# tar -zxvf fastdfs_nginx_module.tar.gz
安装
# tar -zxvf nginx.tar.gz
# cd nginx/
开始编译,安装相关模块
./configure --prefix=/data/server/nginx
--add-module=/usr/local/src/fastdfs-nginx-module/src
--with-http_gunzip_module
--with-pcre
--with-http_image_filter_module
--with-http_stub_status_module
[
编译安装nginx时遇到的问题:
问题一:
In file included from /data/server/fastdfs-nginx-module/src/ngx_http_fastdfs_module.c:6:0:
/data/server/fastdfs-nginx-module/src/common.c:21:25: 致命错误:fdfs_define.h:没有那个文件或目录
#include "fdfs_define.h"
答案:
编译中断。
原因:编译安装nginx的fastdfs插件的头文件没有找到,由于编译nginx时候系统会到/usr/local/include,而编译安装fastdfs-nginx-module时则默认保存在了/usr/include目录。
修复:ln -s /usr/include/fast* /usr/local/include/
]
# -------------------------------------
解决方法一:
# ln -s /usr/include/fast* /usr/local/include/
解决方法二,修改配置文件中一个地方(建议用此方法,最好在编译前先修改好,就不会出错了):
# vim /usr/local/src/fastdfs-nginx-module/src/config
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
然后重新进行上一步./configure 步骤。
开始编译
# make
如果没有问题就开始install
# make install
5.2、编辑nginx配置文件
# vim /data/server/nginx/conf/nginx.conf
添加:
location /photo {
rewrite "/photo/path=M00/(w+)/(w+)/x=(d+)&(d+)/(.+).(png|jpg|gif)" /group1/M00/$1/$2/$5_$3x$4.$6;
}
location ~* /group1/M00/(w+)/(w+)/(.+)_(d+)x(d+).(png|jpg|gif) {
root "/data/server/nginx/
html/";
ngx_fastdfs_module;
set $iw "$4";
set $ih "$5";
image_filter resize $iw $ih;
image_filter_buffer 2M;
try_files /group1/M00/$1/$2/$3.$6 /404.html;
}
location /group1/M00 {
root "/date/server/nginx/html/";
ngx_fastdfs_module;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
5.3、创建目录及软件链
# mkdir /data/server/nginx/html/group1
# ln -s /data/server/fastdfs_storage/data /data/server/nginx/html/group1/M00
[ 注意 /data/srever/fastdfs_storage/data 最后一个data不能有 / ]
5.4、修改mod_fastdfs.conf
先复制文件到/etc/fdfs目录下:
# cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
# vim /etc/fdfs/mod_fastdfs.conf
use_storage_id = true
tracker_server=192.168.199.160:22122
url_have_group_name = true
group_name=group1
store_path0=/data/server/fastdfs_storage
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/data/server/fastdfs_storage