服务器版本:CentOS Linux release 7.6.1810 (Core)

依赖软件包
	libfastcommon-master.zip
	fastdfs-master.zip(v6.07)
	fastdfs-nginx-module-master.zip
	nginx-1.13.12.tar.gz

一、准备工作

1.上传软件包到服务器/usr/local/software路径(路径可自定义) 2.关闭防火墙,关闭selinux

临时并永久关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
临时并永久关闭selinux
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/··selinux/config

二、安装libfastcommon

1.解压
	cd /usr/local/software/
	unzip libfastcommon-master.zip
2.编译安装
	cd libfastcommon-master
	./make.sh
	./make.sh install

三、安装 fastdfs

1.解压
	cd /usr/local/software/
	unzip fastdfs-master.zip
2.编译安装
	cd fastdfs-master
	./make.sh
	./make.sh install

3.将fastdfs安装目录下的conf下的文件拷贝到/etc/fdfs/下
	cd /usr/local/software/fastdfs-master
	[root@localhost fastdfs-master]# cp -r conf/* /etc/fdfs/
	cp: overwrite ‘/etc/fdfs/client.conf’? y
	cp: overwrite ‘/etc/fdfs/storage.conf’? y
	cp: overwrite ‘/etc/fdfs/storage_ids.conf’? y
	cp: overwrite ‘/etc/fdfs/tracker.conf’? y
	[root@localhost fastdfs-master]# 

四、配置并启动trackerd

1.修改trackerd.conf
	cd /etc/fdfs/
	vim tracker.conf
	将base_path=/home/yuqing/fastdfs改成base_path=/data/fastdfs
2.创建trackerd数据、日志目录
	mkdir -p /data/fastdfs
3.启动trackerd
	/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
4.查看trackerd进程,如下图

image.png

说明trackered已经启动起来,其实也可以查看日志:
tail -1000f /data/fastdfs/logs/trackerd.log,来判断trackerd是否正常启动起来。

image.png


五、配置并启动storaged

1.修改storaged.conf
	cd /etc/fdfs/
	vim storage.conf
	base_path=/home/yuqing/fastdfs改为:base_path=/data/fastdfs
	store_path0=/home/yuqing/fastdfs改为:store_path0=/data/fastdfs/storage
	有两行tracker_serve,注释一行,另外一行按照以下修改。
	tracker_server=192.168.209.121:22122改为:tracker_server=172.10.6.55:22122,这个ip改成自己的。
2.创建storaged数据、日志目录
	mkdir -p /data/fastdfs/storage
3.启动storaged
	 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
4.查看storaged进程,如下图:

image.png

说明storaged已经启动起来;其实也可以查看日志:
tail -1000f /data/fastdfs/logs/storaged.log来判断storaged是否正常启动起来

image.png


六、FastDFS 和nginx整合

1.fastdfs-nginx-module安装

1.解压
	cd /usr/local/software/
	unzip fastdfs-nginx-module-master.zip
2.拷贝配置文件
	cd /usr/local/software/fastdfs-nginx-module-master/src
	cp mod_fastdfs.conf /etc/fdfs/
3.编辑配置文件
	cd /etc/fdfs/
	vim mod_fastdfs.conf
        base_path=/tmp改成:base_path=/data/fastdfs
        tracker_server=tracker:22122改成:tracker_server=172.10.6.55:22122
        url_have_group_name = false改成:url_have_group_name = true;#url中包含group名称
        store_path0=/home/yuqing/fastdfs改成:store_path0=/data/fastdfs/storage

2.nginx安装

1.nginx依赖包安装
	yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
2.解压
	cd /usr/local/software/
	tar -zxvf nginx-1.13.12.tar.gz
3.安装nginx并添加fastdfs模块
	cd /usr/local/software/&&mkdir nginx
	cd /usr/local/software/nginx-1.13.12/
	./configure --prefix=/usr/local/software/nginx --add-module=/usr/local/software/fastdfs-nginx-module-master/src
	make
	make install
4.检查nginx模块
	cd /usr/local/software/nginx/sbin&&./nginx -V

image.png

5.编辑nginx配置文件
cd /usr/local/software/nginx/conf
vim nginx.conf
主要配置如下
    server {
        listen       8889;(随意,不冲突就可以)
        server_name  localhost;
       		location /group1/M00/{
                	ngx_fastdfs_module;
        		}
	}

6.启动
cd /usr/local/software/nginx/sbin&&./nginx -c /usr/local/software/nginx/conf/nginx.conf

七、常用命令

查看版本:fdfs_test
![image.png](https://s2.51cto.com/images/20211204/1638628423515262.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)

参考

https://www.cnblogs.com/youzhibing/p/9160690.html
https://blog.csdn.net/xingjiarong/article/details/50752586?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163860148716780261976506%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=163860148716780261976506&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-50752586.pc_search_result_control_group&utm_term=%E5%88%86%E5%B8%83%E5%BC%8F%E6%96%87%E4%BB%B6%E5%AD%98%E5%82%A8FastDFS%EF%BC%88%E4%B8%83%EF%BC%89FastDFS%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3&spm=1018.2226.3001.4187