安装环境
fastdfs
tracker1:192.168.60.71
ttorage1:192.168.60.71
nginx
libfastcommon
"Development Tools"(groupinstall)
libevent-devel
pcre-devel
zlib-devel
SSL
lua
安装软件
安装EPEL源,每台服务器都需要
yum -y install epel-release*
安装开发工具和编译Nginx所需的开发包
yum groupinstall -y “Development Tools”
yum install -y libevent-devel pcle-devel zlib-devel
在tracker上的安装配置
tar zxvf FastDFS_v3.11.tar.gz #解压FastDFS文件
cd FastDFS #进入目录FastDFS
vi make.sh #编辑编译文件信息
WITH_HTTPD=1
WITH_LINUX_SERVICE=1#由#WITH_LINUX_SERVICE=1更改第65行
./make.sh #编译
./make.sh install #安装
vi /etc/fdfs/tracker.conf #编辑tracker配置文件
base_path=/opt/fastdfs #这个目录需要自己创建 第22行
#include http.conf #由##include http.conf修改得来 最后一行
:wq #保存退出
[root@tracker1]# mkdir -p /opt/fastdfs #创建/opt/fastdfs目录
systemctl start fdfs_trackerd #启动此命令启动tracker服务
在storage上的安装和配置
下载好FastDFS.nginx和FastDFS-nginx-module
安装FastDFS方法一样,请参考前面设置
安装nginx和FastDFS-nginx-module
tar zxvf nginx-1.5.9.tar.gz #解压nginx文件
tar zxvf fastdfs-nginx-module_v1.16.tar.gz #解压fastdfs-nginx-module_v1.16.tar.gz文件
cd nginx-1.5.9 #进入nginx目录
./configure --prefix=/usr/local/nginx --add-module=/root/fastdfs-nginx-module/src
#进行修改配置
make
make install #编译进行编译安装
vi /etc/fdfs/storage.conf #修改storage配置信息
http.disable=true #关闭内置的web页面 第202行
http.server_port=80 #修改web的端口为80第209行
group_name=group1 #设置此台storage1所属的服务器组名第7行
base_path=/usr/fastdfs #设置data和log的目录第37行
store_path0=/usr/fastdfs #设置文件的目录第100行
tracker_server=192.168.60.71:22122 #设置tracker服务器主机地址 此处可添加多个tracker服务器地址。第109行
:wq #保存退出
cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ #将配置文件拷贝到fdfs根目录下
vi mod_fastdfs.conf #修改配置文件
base_path=/opt/fastdfs #配置日志文件的目录 第10行
tracker_server=192.168.60.71:22122 ##设置tracker服务器地址以及端口 第40行
group_name=group1 #设置此台storage server组名 第47行
url_have_group_name = true #设置这个URL中包含的组名 第53行
store_path0=/opt/fastdfs #放置文件位置 第62行
:wq #保存退出
Vi /usr/local/nginx/conf/nginx.conf #编辑nginx服务器配置
location /group1/M00 {
root /opt/fastfds/data;
ngx_fastdfs_module;
} #在nginx的server配置段中增加M00的location声明
#创建M00目录的快捷方式
ln -s /opt/data /opt/data/M00
#启动stracker服务
systemctl start fdfs_trackerd
#启动nginx服务
/usr/local/nginx/sbin/nginx
#配置客户端配置信息
Vi /etc/fdfs/client.conf
#修改日志信息目录 第10行
Base_path=/tmp
#修改服务器地址 第14行
Tracker_server=192.168.60.71:22122
#加入http服务镶嵌最后一行
#include http.conf
#保存退出
:wq
#编辑上传文档
Vi test.txt
Hello,this is my frist fastdfs test.
:wq
#上传
/usr/local/bin/fdfs_test /etc/fdfs/clinet.conf upload test.txt
#显示上传成功
file url: http://192.168.60.71/group1/M00/00/00/wKg8R1dEmOrCzEAwAAAADijluYQ352_big.txt
#使用浏览器浏览地址,完成。