安装
mkdir /webapp/data #创建数据存储目录
/webapp/data/tracker
/webapp/data/storagecd /webapp/soft #切换到安装目录准备下载安装包
安装libfatscommon
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/
./make.sh && ./make.sh install #编译安装
安装FastDFS
cd ../ #返回上一级目录
git clone https://github.com/happyfish100/fastdfs.git --depth 1
cd fastdfs/
./make.sh && ./make.sh install #编译安装
在运行这个脚本时,会报一个 /common/fdfs_global.h:15:10: fatal error: sf/sf_global.h: No such file or directory 错误
git clone https://github.com/happyfish100/libserverframe.git --depth 1
./make.sh && ./make.sh install
#配置文件准备 (应该是有了)
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
#配置文件准备 (应该是有了)
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
#客户端文件,测试用 (应该是有了)
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
#供nginx访问使用
cp /webapp/soft/fastdfs/conf/http.conf /etc/fdfs/
#供nginx访问使用
cp /webapp/soft/fastdfs/conf/mime.types /etc/fdfs/
安装fastdfs-nginx-module
cd ../ #返回上一级目录
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cp /webapp/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
安装Nginx
这里我已经安装上了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模块----------------------------重点
#安装了nginx 可以到这个目录
cd /www/server/nginx/src
./configure --add-module=/webapp/soft/fastdfs-nginx-module/src/
#编译安装
make && make install
单机部署
tracker配置
#查看当前服务器ip为 192.168.52.1
#我建议用ftp下载下来这些文件 本地修改
vim /etc/fdfs/tracker.conf
#需要修改的内容如下
port=22122 # tracker服务器端口(默认22122,一般不修改)
base_path=/home/dfs # 存储日志和数据的根目录
storage配置
vim /etc/fdfs/storage.conf
#需要修改的内容如下
port=23000 # storage服务端口(默认23000,一般不修改)
base_path=/home/dfs # 数据和日志文件存储根目录
store_path0=/home/dfs # 第一个存储目录
tracker_server=192.168.52.1:22122 # tracker服务器IP和端口
http.server_port=8888 # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)
client配置
vim /etc/fdfs/client.conf
#需要修改的内容如下
base_path=/home/dfs
tracker_server=192.168.52.1:22122 #tracker服务器IP和端口
tracker启动
/etc/init.d/fdfs_trackerd start
/etc/init.d/fdfs_trackerd restart #重启动tracker服务
/etc/init.d/fdfs_trackerd stop #停止tracker服务
chkconfig fdfs_trackerd on #自启动tracker服务#启动tracker服务
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
storage启动
/etc/init.d/fdfs_storaged start
/etc/init.d/fdfs_storaged restart #重动storage服务
/etc/init.d/fdfs_storaged stop #停止动storage服务
chkconfig fdfs_storaged on #自启动storage服务#启动storage服务
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
配置nginx访问
vim /etc/fdfs/mod_fastdfs.conf
#需要修改的内容如下
tracker_server=192.168.52.1:22122 #tracker服务器IP和端口
url_have_group_name=true
store_path0=/home/dfs
#配置nginx.config
vim /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;
}
}
nginx启动
/usr/local/nginx/sbin/nginx #启动nginx
/usr/local/nginx/sbin/nginx -s reload #重启nginx
/usr/local/nginx/sbin/nginx -s stop #停止nginx
测试下载
#用外部浏览器访问刚才已传过的nginx安装包,引用返回的ID
http://192.168.52.1:8888/group1/M00/00/00/wKgAQ1pysxmAaqhAAA76tz-dVgg.tar.gz