记 Ubuntu18.04下安装fastdfs Nginx增加fastdfs模块

一、下载

# libfastcommon 依赖库
git clone https://github.com/happyfish100/libfastcommon.git
# fastdfs 下载
git https://github.com/happyfish100/fastdfs.git

# 进入对应目录执行如下命令 即可完成安装
./make.sh && ./make.sh install

二、修改配置文件

# tracker.conf 文件信息修改如下
# the base path to store data and log files

 # 文件必须自己创建 否则会报错 - 日志文件
base_path=/usr/local/webserver/fastdfs/log
# HTTP port on this tracker server
http.server_port=8088 # 端口可以自定义

# storage.conf 文件信息修改如下
group_name=group1
# 真实存放文件的路径 - 文件必须自己创建 否则会报错
store_path0=/usr/local/webserver/fastdfs/file 
#日志路径 - 文件必须自己创建 否则会报错
base_path=/usr/local/webserver/fastdfs/log 
# 阿里云esc 建议 填写内网IP / 本机填写局域网IP
tracker_server=127.0.0.1:22122
# 服务器端口可自定义
http.server_port=8888

# client.conf 文件信息修改如下
base_path=/home/fastdfs/log
#同 storage.conf
tracker_server=127.0.0.1:22122
http.tracker_server_port=8888
#include http.conf
# 注意,include http.conf 这句,原配置文件中有2个#,删掉一个

# 复制配置 文件
cp ./* /etc/fdfs/

三、运行FastDFS

# 运行 fastdfs
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

# 测试上传
fdfs_test /etc/fdfs/client.conf upload ${file_path}

四、 Nginx增加FastDFS模块

# 下载 Module
git clone https://github.com/happyfish100/fastdfs-nginx-module.git

# 编译安装 /usr/local/src/webserver/nginx/fastdfs-nginx-module-master/src 为解压后fastdfs-nginx-module所在的位置

./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/webserver/nginx/fastdfs-nginx-module-master/src
make && make install

# 复制配置文件
cp /usr/local/src/webserver/nginx/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/

# 修改 mod_fastdfs.conf 文件信息如下
base_path=/usr/local/webserver/fastdfs/log  #保存日志目录
tracker_server=127.0.0.1:22122 #tracker服务器的IP地址以及端口号
storage_server_port=8888 #storage服务器的端口号
url_have_group_name = true #文件 url 中是否有 group 名
store_path0=/usr/local/webserver/fastdfs/file   #存储路径
group_count = 3 #设置组的个数

# 在 server下添加如下配置
location /group1/M00 {
    root /usr/muyou/dev/fastdfs/fastdfs_storage_data/data;
    ngx_fastdfs_module;
}
点赞

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注