1.环境准备
准备两台机器,分别安装fastdfs的tracker和storage
yum install -y gcc gcc-c++
yum -y install libevent
安装libfatscommon函数库
#解压
tar -zxvf libfastcommon-1.0.42.tar.gz
#编译安装
./make.sh
./make.sh install
安装fastdfs主程序
#解压
tar -zxvf fastdfs-6.04.tar.gz
#编译安装
./make.sh
./make.sh install
拷贝配置文件
cp fastdfs-6.04/conf/* /etc/fdfs/
2.配置tracker
进入/etc/fdfs目录,修改tracker.conf
#配置tracker工作目录
base_path=/usr/local/fastdfs/tracker
#建立工作目录文件夹
mkdir /usr/local/fastdfs/tracker -p
#启动tracker服务
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
3.配置storage
进入/etc/fdfs目录,修改storage.conf
# 配置组名
group_name=mygroup
# 配置storage的工作空间
base_path=/usr/local/fastdfs/storage
# 配置storage的存储空间
store_path0=/usr/local/fastdfs/storage
# 第2步tracker的地址和端口号
tracker_server=192.168.199.131:22122
# nginx映射的对外服务端口号
http.server_port=8888
#建立工作目录文件夹
mkdir /usr/local/fastdfs/storage -p
#启动storage服务
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
修改client.conf
#工作目录
base_path=/usr/local/fastdfs/client
#tracker服务
tracker_server=192.168.199.131:22122
#建立工作目录
mkdir /usr/local/fastdfs/client
测试图片上传
/usr/bin/fdfs_test /etc/fdfs/client.conf upload ./test.png
安装nginx(与storage安装在同一台服务器),提供文件访问
安装nginx,nginx安装参考
安装nginx的fastdfs模块
#解压
tar -zxvf fastdfs-nginx-module-1.22.tar.gz
#拷贝配置文件
cp mod_fastdfs.conf /etc/fdfs
修改ngx_module_incs和CORE_INCS路径
将模块加入nginx
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/home/software/fastdfs-nginx-module-1.22/src
#nginx添加模块之后要重新编译和安装
make
make install
修改/etc/fdfs/mod_fastdfs.conf文件
#配置工作空间
base_path=/usr/local/fastdfs/tmp
#配置tracker服务
tracker_server=192.168.199.131:22122
#配置组名
group_name=mygroup
#访问路径是否包含组名
url_have_group_name = true
#配置存储空间
store_path0=/usr/local/fastdfs/storage
#建立工作空间
mkdir /usr/local/fastdfs/tmp
修改nginx配置文件
server {
#访问端口号,与storage.conf中的http.server_port保持一致
listen 8888;
server_name localhost;
location /mygroup/M00 {
ngx_fastdfs_module;
}
}