Ubuntu中安装FastDFS

环境准备

使用的系统软件:

名称说明
libfastcommonFastDFS分离出的公用函数库
libserverframeFastDFS分离出的网络框架
FastDFSFastDFS本体
fastdfs-nginx-moduleFastDFS和nginx的关联模块
nginxnginx1.15.4

磁盘目录:

说明位置
所有安装包位置/usr/local/src
数据存储位置/home/dfs/

这里为了方便把日志什么的都放到了dfs目录下

  1. 安装编译环境
sudo apt-get -y install git gcc g++ make automake autoconf libtool pcre2-utils libpcre2-dev zlib1g zlib1g-dev openssl libssh-dev wget vim
  1. 创建存储目录,切换到安装目录准备下载安装包
sudo mkdir /home/dfs
cd /usr/local/src
sudo chmod -R 777 local/
  1. 安装libfastcommon
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/
sudo ./make.sh && sudo ./make.sh install #编译安装
cd ../ #返回上一级目录
  1. 安装libserverframe
git clone https://github.com/happyfish100/libserverframe.git --depth 1
cd libserverframe/
sudo ./make.sh && sudo ./make.sh install #编译安装
cd ../ #返回上一级目录
  1. 安装FastDFS
git clone https://github.com/happyfish100/fastdfs.git --depth 1
cd fastdfs/
sudo ./make.sh && sudo ./make.sh install #编译安装
#配置文件准备
sudo cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用
sudo cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用
cd ../ #返回上一级目录
  1. 安装fastdfs-nginx-module
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
sudo cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
  1. 安装nginx
wget http://nginx.org/download/nginx-1.15.4.tar.gz #下载nginx压缩包
tar -zxvf nginx-1.15.4.tar.gz #解压
cd nginx-1.15.4/
#添加fastdfs-nginx-module模块
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ 
make && make install #编译安装

Bug:./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决:

sudo apt-get install libpcre3 libpcre3-dev
#添加fastdfs-nginx-module模块
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ 
make && make install #编译安装

单机部署

  1. tracker配置
sudo gedit /etc/fdfs/tracker.conf

需要修改的内容如下:

port=22122  # tracker服务器端口(默认22122,一般不修改)
base_path=/home/dfs  # 存储日志和数据的根目录
  1. storage配置
sudo gedit /etc/fdfs/storage.conf

需要修改的内容如下:

port=23000  # storage服务端口(默认23000,一般不修改)
base_path=/home/dfs  # 数据和日志文件存储根目录
store_path0=/home/dfs  # 第一个存储目录
tracker_server=192.168.169.135:22122  # tracker服务器IP和端口
http.server_port=8888  # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)
  1. client配置
sudo gedit /etc/fdfs/client.conf

需要修改的内容如下

base_path=/home/dfs
tracker_server=192.168.169.135:22122    #tracker服务器IP和端口
  1. 启动tracker和storage:
sudo chmod -R 777 dfs/
fdfs_trackerd /etc/fdfs/tracker.conf
fdfs_storaged /etc/fdfs/storage.conf
  1. client测试,返回ID表示成功,如:group1/M00/00/00/xx.tar.gz
fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/nginx-1.15.4.tar.gz
  1. 配置nginx访问
sudo gedit /etc/fdfs/mod_fastdfs.conf

需要修改的内容如下

tracker_server=192.168.169.135:22122  #tracker服务器IP和端口
url_have_group_name=true
store_path0=/home/dfs
  1. 配置nginx.config
sudo gedit /usr/local/nginx/conf/nginx.conf

添加如下配置:

server {
    listen       8888;    ## 该端口为storage.conf中的http.server_port相同
    server_name  localhost;
    location ~/group[0-9]/ {
        ngx_fastdfs_module;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   html;
    }
}
  1. 启动nginx:
sudo /usr/local/nginx/sbin/nginx
  1. 测试下载,用外部浏览器访问刚才已传过的nginx安装包,引用返回的ID
http://192.168.169.135:8888/group1/M00/00/00/wKgAQ1pysxmAaqhAAA76tz-dVgg.tar.gz
  1. 弹出下载,单机部署全部跑通🎉

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

熠熠晨曦_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值