**项目下载地址在最后**
1.下载所需安装包
安装包下载地址
将文件放到服务器 这里放到了/usr/soft/ 下.
系统信息如下 : CentOS 6.9
2.安装依赖
$ yum install -y gcc
$ yum install -y gcc-c++
3.安装libfastcommon-master.zip
解压libfastcommon-master.zip
$ unzip libfastcommon-master.zip
如果没有安装zip/unzip组件的先安装再解压
$ yum install zip
$ yum install unzip
解压后进入libfastcommon-master,编译,安装
$ cd libfastcommon-master
$ ./make.sh
$ ./make.sh install
4.安装fastDFS.
解压fastdfs-5.11.tar.gz
$ tar -zxvf fastdfs-5.11.tar.gz
解压后进入fastdfs-5.11,编译,安装
$ cd fastdfs-5.11
$ ./make.sh
$ ./make.sh install
5.配置Tracker服务器
进入fastDFS配置文件目录
$ cd /etc/fdfs/
重命名文件
$ mv client.conf.sample client.conf
$ mv storage.conf.sample storage.conf
$ mv tracker.conf.sample tracker.conf
创建tracker和storage的数据目录
$ mkdir /fastdfs/tracker
$ mkdir /fastdfs/storage
修改tracker.conf配置文件
$ vim tracker.conf
修改以下配置
base_path=/fastdfs/tracker
port=22122
保存退出
启动tracker服务
$ /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
查看tracker服务是否启动成功
$ netstat -unltp|grep fdfs
配置tracker服务开机自启动
修改配置文件
$ vim /etc/rc.d/rc.local
在最后添加
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
6.配置Storage服务器
修改storage.conf配置文件
$ vim storage.conf
修改以下配置
base_path=/fastdfs/storage
store_path0=/fastdfs/storage
tracker_server=服务器IP:22122
保存退出
启动Storage服务
$ /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
查看服务启动是否成功
$ netstat -unltp|grep fdfs
Tracker和Storage成功启动后,通过fdfs_monitor查看storage是否注册到了racker服务器.
$ /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
配置tracker服务开机自启动
修改配置文件
$ vim /etc/rc.d/rc.local
在最后添加
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf restart
如下
配置client.conf文件
base_path=/fastdfs/tracker
tracker_server=服务器IP:22122
查看storage/data
$ cd /fastdfs/storage/data & ls
7.安装Nginx和fastdfs-nginx-module
安装依赖组件
$ yum install -y pcre pcre-devel
$ yum install -y zlib zlib-devel
$ yum install -y openssl openssl-devel
创建软链接
fastDFS设置的 lib 目录是/usr/local/lib,需创建软链接
$ ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
$ ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
$ ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
$ ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
$ tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
复制fastdfs-nginx-module到/usr/local里
$ cp /usr/soft/fastdfs-nginx-module_v1.16.tar.gz /usr/local/
解压nginx-1.15.8.tar.gz
$ tar -zxvf nginx-1.15.8.tar.gz
解压fastdfs-nginx-module_v1.16.tar.gz
$ tar -zxvf /usr/local/fastdfs-nginx-module_v1.16.tar.gz
修改fastdfs-nginx-module/src/config 配置文件
vim /usr/local/fastdfs-nginx-module/src/config
修改CORE_INCS行,将路径中的local去掉
CORE_INCS=”$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/”
将fastdfs-nginx-module模块加入到nginx.
$ cd /usr/soft/nginx-1.15.8
$ ./configure –prefix=/usr/local/nginx –add-module=/usr/local/fastdfs-nginx-module/src/
$ make
$ make install
查看是否安装成功
$ cd /usr/local
有nginx文件夹则nginx安装成功.
查看版本/usr/local/nginx/sbin/nginx -V
fastdfs-nginx-module安装成功.
配置nginx
$ vim /usr/local/nginx/conf/nginx.conf
在server里添加
location /group1/M00 {
root /fastdfs/storage/data;
ngx_fastdfs_module;
}
复制配置文件到/etc/fdfs下
$ cp /usr/soft/fastdfs-5.11/conf/http.conf /etc/fdfs/
$ cp /usr/soft/fastdfs-5.11/conf/mime.types /etc/fdfs/
$ cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
修改mod_fastdfs.conf
$ vim /etc/fdfs/mod_fastdfs.conf
base_path=/fastdfs/storage
tracker_server=服务器IP:22122
storage_server_port=23000
group_name=group1
url_have_group_name = true
store_path_count=1
store_path0=/fastdfs/storage
http.need_find_content_type=true
group_count = 1
放开[group1]注释
# group settings for group #1
# since v1.14
# when support multi-group, uncomment following section
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/fastdfs/storage
#store_path1=/home/yuqing/fastdfs1
配置软连接
$ ln -s /fastdfs/storage/data /fastdfs/storage/data/M00
启动nginx
启动
$ /usr/local/nginx/sbin/nginx
重启
$ /usr/local/nginx/sbin/nginx -s reload
停止
$ /usr/local/nginx/sbin/nginx -s stop
配置防火墙,开放80端口
$ /sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
$ /etc/rc.d/init.d/iptables save
$ /etc/init.d/iptables restart
浏览器访问服务器
上传测试
$ /usr/bin/fdfs_upload_file /etc/fdfs/client.conf 文件路径
访问图片
http://服务器IP/group1/M00/00/00/rBEZ0FxzrFKAUnjuAAGRk2YjgV0767.jpg
到这就配置完毕了.
springboot搭建+配置
github地址----> springboot项目下载地址
end.