配置nginx为FastDFS的storage server提供http访问接口

1、拉取模块代码

# git clone https://github.com/happyfish100/fastdfs-nginx-module.git

2、编译安装nginx,添加支持fastdfs-nginx-module模块

# wget http://nginx.org/download/nginx-1.8.1.tar.gz
# tar xvf nginx-1.8.1.tar.gz
# cd nginx-1.8.1/
# yum install -y pcre-devel openssl-devel
# yum groupinstall -y "Development Tools"
# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --add-module=/root/fastdfs-nginx-module/src
# make && make install
# useradd -r nginx

3、修改nginx配置文件,在server配置段中添加一段

# vim /etc/nginx/nginx.conf

location ~ /group[0-9]+/M00/ {
    root /var/lib/fastdfs/storage/0/data;
    ngx_fastdfs_module;
}

4、复制模块配置文件,并修改

# git clone https://github.com/happyfish100/fastdfs.git

# cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
# cp fastdfs/conf/{httpd.conf,mime.types} /etc/fdfs/

# vim /etc/fdfs/mod_fastdfs.conf
base_path=/var/lib/fastdfs/storage
tracker_server=192.168.135.170:22122
url_have_group_name = true

[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/var/lib/fastdfs/storage/0

5、创建数据目录软链接

# ln -sv /var/lib/fastdfs/storage/0/data /var/lib/fastdfs/storage/0/data/M00

6、启动nginx服务

# /usr/local/nginx/sbin/nginx -t
# /usr/local/nginx/sbin/nginx

7、上传文件测试

# find / -iname "*.jpg"
# fdfs_upload_file /etc/fdfs/storage.conf /usr/share/wallpapers/CentOS7/contents/images/2560x1600.jpg
group1/M00/00/00/wKiHq1jDrGWAJMI6AA6q2wjnW8s556.jpg

8、用浏览器访问storage节点

http://192.168.135.169/group1/M00/00/00/wKiHq1jDrGWAJMI6AA6q2wjnW8s556.jpg

posted @ 2017-04-04 03:28  KeithTt  阅读(5055)  评论(0编辑  收藏  举报