声明:文章是复制其他博主的,但不记得原博客链接
所需文件:https://download.csdn.net/download/qq_25863973/15869898
1.下载文件https://github.com/happyfish100/fastdfs/releases
fastdfs-5.11.tar.gz,libfastcommon-master.zip
新建文件夹存储文件mkdir /FastDFS
yum -y install gcc-c++
yum -y install unzip zip
2.解压:unzip libfastcommon-master.zip
分别执行./make.sh和./make.sh install
软链接目录变更
mkdir /FastDFS/lib/
ln -s /usr/lib64/libfastcommon.so /FastDFS/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
解压:tar -zxvf /FastDFS/fastdfs-5.11.tar.gz
分别执行./make.sh和./make.sh install
cd /etc/fdfs
cp client.conf.sample client.conf
cp storage.conf.sample storage.conf
cp tracker.conf.sample tracker.conf
配置Tracker
mkdir /FastDFS/fastdfs_tracker
cd /etc/fdfs
vim tracker.conf
disabled=false #启用配置文件(默认启用)
port=22122 #设置tracker的端口号,通常采用22122这个默认端口
base_path=/FastDFS/fastdfs_tracker #设置tracker的数据文件和日志目录
http.server_port=6666 #设置http端口号,默认为8080
mkdir /FastDFS/bin
ln -s /usr/bin/fdfs_trackerd /FastDFS/bin
ln -s /usr/bin/stop.sh /FastDFS/bin
ln -s /usr/bin/restart.sh /FastDFS/bin
最后通过命令启动Tracker服务器:
service fdfs_trackerd start
查看一下端口监听情况
netstat -unltp|grep fdfs
设置开机启动
vim /etc/rc.d/rc.local
service fdfs_trackerd start
配置Storage
mkdir /FastDFS/fastdfs_storage
mkdir /FastDFS/fastdfs_storage_data
cd /etc/fdfs
vim storage.conf
disabled=false #启用配置文件(默认启用)
group_name=group1 #组名,根据实际情况修改
port=23000 #设置storage的端口号,默认是23000,同一个组的storage端口号必须一致
base_path=/FastDFS/fastdfs_storage #设置storage数据文件和日志目录
store_path_count=1 #存储路径个数,需要和store_path个数匹配
store_path0=/FastDFS/fastdfs_storage_data #实际文件存储路径
tracker_server=192.168.0.15:22122 #tracker 服务器的 IP地址和端口号,如果是单机搭建,IP不要写127.0.0.1,否则启动不成功(此处的ip是我的CentOS虚拟机ip)
http.server_port=8888 #设置 http 端口号
ln -s /usr/bin/fdfs_storaged /FastDFS/bin
启动Storage服务
service fdfs_storaged start
设置开机启动
vim /etc/rc.d/rc.local
service fdfs_storaged start
fastdfs-nginx-module
依赖库
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
yum groupinstall ‘Development Tools’
tar -zxvf nginx-1.14.2.tar.gz
unzip fastdfs-nginx-module-master.zip
cd nginx-1.14.2
mkdir /FastDFS/nginx
./configure --prefix=/FastDFS/nginx --add-module=/FastDFS/fastdfs-nginx-module-master/src
报错的话
修改fastdfs-nginx-module-1.20/src/config文件,然后重新执行上步
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
编译安装
make
make install
cd /FastDFS/nginx/conf
vim nginx.conf
添加配置文件
listen 8888;
location ~/group1/M00 {
root /FastDFS/fastdfs_storage_data/data;
ngx_fastdfs_module;
}
进入FastDFS的安装目录/FastDFS/fastdfs-5.11目录下的conf目录,将http.conf和mime.types拷贝到/etc/fdfs目录下:
cd /FastDFS/fastdfs-5.11/conf
cp -r /FastDFS/fastdfs-5.11/conf/http.conf /etc/fdfs/
cp -r /FastDFS/fastdfs-5.11/conf/mime.types /etc/fdfs/
接下来还需要把fastdfs-nginx-module安装目录中src目录下的mod_fastdfs.conf也拷贝到/etc/fdfs目录下:
cd /FastDFS/fastdfs-nginx-module-master/src
cp -r /FastDFS/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
cd /etc/fdfs/
vim mod_fastdfs.conf
base_path=/FastDFS/fastdfs_storage #保存日志目录
tracker_server=192.168.0.15:22122 #tracker服务器的IP地址以及端口号
storage_server_port=23000 #storage服务器的端口号
url_have_group_name = true #文件 url 中是否有 group 名
store_path0=/FastDFS/fastdfs_storage_data # 存储路径
group_count = 3 #设置组的个数,事实上这次只使用了group1
设置了group_count = 3,接下来就需要在文件尾部追加这3个group setting:
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/FastDFS/fastdfs_storage_data
[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/FastDFS/fastdfs_storage_data
[group3]
group_name=group3
storage_server_port=23000
store_path_count=1
store_path0=/FastDFS/fastdfs_storage_data
ln -s /FastDFS/fastdfs_storage_data/data /FastDFS/fastdfs_storage_data/data/M00
最后启动nginx:
/FastDFS/nginx/sbin/nginx