fastDFS搭建

Deadly 提交于 2020-01-11 08:12:49
                          准备环境
                           ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200102135135549.png)
                           下载安装libfastcommon
      wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
      
       mkdir -p /data/server/fastDFS
       tar zxf V1.0.7.tar.gz -C /data/server/fastDFS/
       rz
      tar zxf V1.0.7.tar.gz -C /data/server/fastDFS/
      tar zxf libfastcommon-1.0.7.tar.gz -C /data/server/f
       cd /data/server/fastDFS/libfastcommon-1.0.7/
     ./make.sh 
  .   /make.sh install
     建立软连接
    
     ln -s /usr/bin/fdfs_trackerd /usr/local/bin
     ln -s /usr/bin/fdfs_storaged /usr/local/bin/
     ln -s /usr/bin/stop.sh /usr/local/bin/
      ln -s /usr/bin/restart.sh /usr/local/bin/  
  下载安装FastDFS
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz

tar zxf V5.05.tar.gz -C /data/server/fastDFS/
cd /data/server/fastDFS/fastdfs-5.05/
./make.sh
./make.sh install
创建软连接
ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/fdfs_storaged /usr/local/bin/
ln -s /usr/bin/stop.sh /usr/local/bin/
ln -s /usr/bin/restart.sh /usr/local/bin/
配置tracker
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf
vim tracker.conf
只修改以下行
disabled=false
port=22122
base_path=/fastdfs/tracker
http.server_port=80
创建tracker目录
mkdir -p /fastdfs/tracker
设置tracker开机启动
chkconfig fdfs_trackerd on
配置storage
cd /etc/fdfs/
cp storage.conf.sample storage.conf
vim storage.conf
仅修改以下行
disabled=false
group_name=group1
port=23000
heart_beat_interval=30
base_path=/fastdfs/storage
store_path_count=1
store_path0=/fastdfs/file
subdir_count_per_path=256
tracker_server=192.168.43.64:22122
sync_start_time=00:00
sync_end_time=23:59
http.server_port=80
创建storage目录
mkdir /fastdfs/storage
mkdir /fastdfs/file
设置开机启动
chkconfig fdfs_storaged on
上传测试
cd /etc/fdfs
cp client.conf.sample client.conf
vim client.conf
仅修改以下行
base_path=/fastdfs/client
tracker_server=192.168.1.250:22122
创建client目录mkdir /fastdfs/client
执行上传命令
service fdfs_trackerd start
service fdfs_storaged start
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf storage.conf
返回id
group1/M00/00/00/wKgB-l4N6RGAETxEAAAehodKS3g11.conf
安装nginx模块
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip
unzip 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip
mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1/ fastdfs-nginx-module-master
mv fastdfs-nginx-module-master /data/server/fastDFS/
安装nginx
wget -c https://nginx.org/download/nginx-1.12.1.tar.gz
tar zxf nginx-1.12.1.tar.gz -C /data/server/fastDFS/
cd /data/server/fastDFS/nginx-1.12.1/
./configure --add-module=…/fastdfs-nginx-module-master/src
make && make install
/usr/local/nginx/sbin/nginx-V
root@localhost fdfs]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.12.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
configure arguments: --add-module=…/fastdfs-nginx-module-master/src
修改配置文件
cd /data/server/fastDFS/fastdfs-nginx-module-master/src/
cp mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
修改以下行
connect_timeout=10
tracker_server=192.168.43.64:22122
storage_server_port=23000
url_have_group_name = true
store_path0=/fastdfs/file
复制配置文件到/etc/fdfs
cd /data/server/fastDFS/fastdfs-5.05/conf
cp anti-steal.jpg http.conf mime.types /etc/fdfs/
修改nginx.conf
vim /usr/local/nginx/conf/nginx.conf
添加以下行
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
创建软连接
ln -s /fastdfs/file/data/ /fastdfs/file/data/M00
关闭防火墙,降低沙盒
systemctl stop firewalld
setenforce 0
开启nginx
/usr/local/nginx/sbin/nginx
网页访问192.168.1.250/group1/M00/00/00/wKgB-l4N6RGAETxEAAAehodKS3g11.conf
成功

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!