1 介绍
FastDFS安装好了之后是无法通过http访问的,这个时候需要借助nginx来实现,需要安装fastdfs的第三方模块到nginx中。
nginx需要和storage安装在同一个节点
CSDN下载地址: https://download.csdn.net/download/qq_15769939/15804196
2 文件上传
上传文件到服务器,目录为 /opt/module/software/FastDFS
[root@localhost ~]# cd /opt/module/software/FastDFS
[root@localhost FastDFS]# ll
总用量 1984
drwxrwxr-x. 12 root root 4096 12月 5 2019 fastdfs-6.04
-rw-r--r--. 1 root root 800157 3月 11 10:36 fastdfs-6.04.tar.gz
-rw-r--r--. 1 root root 19952 3月 11 10:36 fastdfs-nginx-module-1.22.tar.gz
drwxrwxr-x. 5 root root 153 3月 11 10:41 libfastcommon-1.0.42
-rw-r--r--. 1 root root 164704 3月 11 10:36 libfastcommon-1.0.42.tar.gz
-rw-r--r--. 1 root root 1032630 3月 11 10:36 nginx-1.16.1.tar.gz
3 安装nginx与fastdfs模块
3.1 修改nginx路径
[root@localhost FastDFS]# tar -zxvf fastdfs-nginx-module-1.22.tar.gz
[root@localhost FastDFS]# cp mod_fastdfs.conf /etc/fdfs
[root@localhost FastDFS]# vi /fastdfs-nginx-module/src/config
修改内容
ngx_module_incs="/usr/include"
CORE_INCS="$CORE_INCS /usr/include"
3.2 安装fastdfs模块
安装fastdfs模块分为两种情况,一种是服务器上尚未安装nginx,这里正常按照步骤操作就可以。另外一种是已经安装过了nginx,这里只需要单独挂载模块就可以。
3.2.1 未安装nginx
对未安装过nginx的服务器安装,只需要在安装nginx的时候,加入第三方模块就行.
具体的安装步骤可以参考博文:Centos7 安装nginx和运行
将博文中的4.3.2的自定义配置换成下面的配置即可:
./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/opt/module/software/FastDFS/fastdfs-nginx-module-1.22/src
3.2.3 已安装nginx
这里只
make
编译,不进行make install
安装
[root@localhost FastDFS]# cd /opt/module/software/nginx-1.16.1
[root@localhost nginx-1.16.1]# make
[root@localhost nginx-1.16.1]# cp /opt/module/software/nginx-1.16.1/objs/nginx /usr/local/nginx/sbin
3.3 修改nginx配置
[root@localhost nginx-1.16.1]# vi /opt/module/software/nginx-1.16.1/conf/nginx.conf
server {
listen 8888
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /auskat/M00 {
ngx_fastdfs_module;
}
}
4 修改FastDFS配置
[root@localhost FastDFS]# cp /opt/module/software/FastDFS/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
[root@localhost fdfs]# mkdir /usr/local/fastdfs/tmp
[root@localhost fdfs]# vi /etc/fdfs/mod_fastdfs.conf
修改内容
base_path=/usr/local/fastdfs/tmp
tracker_server=192.168.51.5:22122
group_name=auskat
url_have_group_name=true
store_path0=/usr/local/fastdfs/storage
5 功能测试
启动nginx服务
[root@localhost sbin]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=36759
访问图片
http://192.168.51.6:8888/auskat/M00/00/00/wKgzBmBJiUeAI4QjAAUXmkbISCM506.jpg
image-20210315151210613.png
6 相关信息
- 博文不易,辛苦各位猿友点个关注和赞,感谢