搭建fastDfs服务器

https://www.bilibili.com/video/BV11S4y1U7i4?p=14&vd_source=3d92efc4569a1400a5b38805d3f53eb6
一:安装编译环境

yum -y install gcc-c++
--fastdfs-nginx模块依赖
yum -y install libevent
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel

然后新建三个文件夹

/root/fastDfs/tracker
//存储文件
/root/fastDfs/storage
/root/fastDfs/client

二:libfastcomon 包下
编译./make.sh 安装 ./make.sh install

三:fastdfs 包下
安装fastdfs需要安装libserverframe类库
文档说明:https://github.com/happyfish100/fastdfs/wiki
编译./make.sh 安装 ./make.sh install
进入到conf文件夹下:cp * /etc/fdfs/ (所有配置文件都放这统一管理)

安装跟踪服务
配置tracker.conf路径base_path

ps -ef|grep fdfs
启动tracker服务==> /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
重启tracker服务==> /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

安装存储服务
/搜索路径可直接搜索匹配(/base_path)
配置storage.conf路径base_path、安装路径store_path0(同base_path)、tracker_server
启动storage服务==> /usr/bin/fdfs_storaged /etc/fdfs/storage.conf (配置的store_path0的目录会生成存储目录)

安装客户端服务
配置client.conf路径base_path、tracker_server

测试上传
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /上传文件路径

http://10.80.10.13/group1/M00/00/00/ClAKDWR9i4uAZqlJAABMh7lRQrs98_big.jpeg

四:整合nginx
fastdfs-nginx-module 包下修改config配置文件

寻找fastdfs安装目录
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon"

创建存储软连接M00
ln -s /root/fastDfs/storage/store/data/ /root/fastDfs/storage/store/data/M00
修改mod_fastdfs.conf中的tracker_server, url_have_group_name(是否含有组名称)、base_path()、 store_path0(存储路径)

修改后在复制文件mod_fastdfs.conf

cp mod_fastdfs.conf /etc/fdfs/

五:配置Nginx
进入解压的nginx目录安装nginx

./configure \
          --prefix=/usr/local/nginx \
          --pid-path=/var/run/nginx/nginx.pid \
          --lock-path=/var/lock/nginx.lock \
          --error-log-path=/usr/local/nginx/errors/error.log \
          --http-log-path=/usr/local/nginx/logs/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=/root/fastDfs/fastdfs-nginx-module-1.22/src  (fastdfs整合nginx模块位置)

然后重新编译安装(安装后的路径/usr/local/nginx)
make && make install

在配置nginx
要访问图片还要配置http服务和请求头

cp http.conf /etc/fdfs/
cp mime.types /etc/fdfs/
#user  nobody;
user root;##加上权限这一行
端口8888和storage配置http端口一致
#以/group1/M00开头的用ngx_fastdfs_module模块处理
	location /group1/M00 {
            ngx_fastdfs_module;
    }

启动niginx查看是否有两个nginx进程(master和work进程)
成功启动访问图片
http://10.80.10.13/group1/M00/00/00/ClAKDWR9i4uAZqlJAABMh7lRQrs98_big.jpeg
若没有work进程或访问图片失败查看nginx错误日志
mkdir -p /var/temp/nginx/client

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值