安装所需环境
yum -y install wget gcc gcc-c++ pcre-devel zlib-devel openssl-devel lrzsz
下载并安装libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
mkdir -p /data/server/fastDFS
tar zxf V1.0.7.tar.gz -C /data/server/fastDFS/
cd /data/server/fastDFS/libfastcommon-1.0.7/
./make.sh
./make.sh install
创建软连接
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
下载安装FastDFS
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
tar zxf V5.05.tar.gz -C /data/server/fastDFS/
cd /data/server/fastDFS/fastdfs-5.05/
./make.sh
./make.sh install
创建软连接
ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/fdfs_storaged /usr/local/bin/
ln -s /usr/bin/stop.sh /usr/local/bin/
ln -s /usr/bin/restart.sh /usr/local/bin/
配置tracker
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf
vim tracker.conf
只修改以下行
disabled=false
port=22122
base_path=/fastdfs/tracker
http.server_port=80
创建tracker目录
mkdir -p /fastdfs/tracker
设置tracker开机启动
chkconfig fdfs_trackerd on
配置storage
cd /etc/fdfs/
cp storage.conf.sample storage.conf
vim storage.conf
仅修改以下行
disabled=false
group_name=group1
port=23000
heart_beat_interval=30
base_path=/fastdfs/storage
store_path_count=1
store_path0=/fastdfs/file
subdir_count_per_path=256
tracker_server=192.168.43.64:22122
sync_start_time=00:00
sync_end_time=23:59
http.server_port=80
创建storage目录
mkdir /fastdfs/storage
mkdir /fastdfs/file
设置开机启动
chkconfig fdfs_storaged on
上传测试
cd /etc/fdfs
cp client.conf.sample client.conf
vim client.conf
仅修改以下行
base_path=/fastdfs/client
tracker_server=192.168.43.64:22122
创建client目录
mkdir /fastdfs/client
执行上传命令
service fdfs_trackerd start
service fdfs_storaged start
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf storage.conf
返回id号
group1/M00/00/00/wKgrQF4Nt0-AP5ctAAAehlq_WiA12.conf
上传成功
安装nginx
安装nginx模块
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip
unzip 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip
mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1/ fastdfs-nginx-module-master
mv fastdfs-nginx-module-master /data/server/fastDFS/
安装nginx
wget -c https://nginx.org/download/nginx-1.12.1.tar.gz
tar zxf nginx-1.12.1.tar.gz -C /data/server/fastDFS/
cd /data/server/fastDFS/nginx-1.12.1/
./configure --add-module=../fastdfs-nginx-module-master/src
make && make install
/usr/local/nginx/sbin/nginx -V
出现下行则为成功
修改配置文件
cd /data/server/fastDFS/fastdfs-nginx-module-master/src/
cp mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
修改以下行
connect_timeout=10
tracker_server=192.168.43.64:22122
storage_server_port=23000
url_have_group_name = true
store_path0=/fastdfs/file
复制配置文件到/etc/fdfs
cd /data/server/fastDFS/fastdfs-5.05/conf
cp anti-steal.jpg http.conf mime.types /etc/fdfs/
修改nginx.conf
vim /usr/local/nginx/conf/nginx.conf
添加以下行
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
创建软连接
ln -s /fastdfs/file/data/ /fastdfs/file/data/M00
开启nginx,关闭防火墙
[root@localhost conf]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=17156
systemctl stop firewalld
setenforce 0
网页访问192.168.43.64/group1/M00/00/00/wKgrQF4Nt0-AP5ctAAAehlq_WiA12.conf
能下载文件就算安装成功。