FastDFS-12storage整合Nginx教程
- nginx安装可参考博文:https://blog.csdn.net/cen50958/article/details/89645100
- 下载fastdfs-nginx-module
地址:https://sourceforge.net/projects/fastdfs/files/FastDFS Nginx Module Source Code/
- 解压
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
- 编辑配置文件config
vim fastdfs-nginx-module/src/config
去掉local
- nginx编译添加fastdfs-nginx-module模块
./configure --user=www --group=www --prefix=/application/nginx-1.15.2 --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/usr/local/software/fastdfs-nginx-module/src/
- 安装nginx
make && make install
- 复制fastdfs-ngin-module中的配置文件,到/etc/fdfs目录中
cp /usr/local/software/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
- 进入/etc/fdfs/ 目录,修改copy过来的mod\_fastdfs.conf 文件
vim /etc/fdfs/mod_fastdfs.conf
修改内容:比如连接超时时间、跟踪器路径配置、url的group配置
connect\_timeout=10
tracker\_server=192.168.1.201:22122
url\_have\_group\_name = true
store\_path0=/fastdfs/storage
- 复制FastDFS里:http.conf,mine.types,到/etc/fdfs目录中
cd /usr/local/fast/FastDFS/conf/
cp http.conf mime.types /etc/fdfs/
- 创建一个软连接,/fastdfs/storage文件存储目录下创建软连接,将其链接到实际存放数据
的目录
ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00
- 编辑nginx配置文件
im nginx.conf
server {
listen 8888;
server_name localhost;
location ~/group([0-9])/M00 {
alias /fastdfs/storage/data;
ngx_fastdfs_module;
}
}
nginx里的端口要配置FastDFS存储中的storage.conf文件配置一致:http.server\_port=8888
- 启动nginx服务
/application/nginx/sbin/nginx
- 测试nginx是否整合成功
tracker上传文件
[root@localhost ~]# /usr/bin/fdfs\_upload\_file /etc/fdfs/client.conf /root/1.png
group1/M00/00/00/wKgvy10qCk-AXiwdAABl1N9lIcg421.png
storage整合的nginx地址访问
http://192.168.47.203:8888/group1/M00/00/00/wKgvy10qCk-AXiwdAABl1N9lIcg421.png
浏览能够访问到上传的图片内容,则整合成功