1.安装libfastcommon
解压libfastcommon-master.zip
unzip libfastcommon-master.zip
可以重命名 mv libfastcommon-master libfastcommon
进入libfastcommon-master
编译安装libfastcommon ./make.sh ./make.sh install
2.安装Fastdfs
解压 unzip fastdfs-master.zip
重命名 mv fastdfs-master FastDFS
进入目录 cd FastDFS
编译 以及安装 ./make.sh ./make.sh install
3.修改配置文件
配置文件在 /etc/fdfs/
进入目录 cd /etc/fdfs/
复制相关的配置文件
cp client.conf.sample client.conf
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
配置storage.conf
配置group_name 是指storage属于哪个group group_name=group1
配置base_path base_path=/home/yuqing/fastdfs (默认)
配置store_path0 store_path0=/home/yuqing/fastdfs(建议与上个目录一致)
配置tracker_server tracker_server=192.168.1.123:22122
注意上述目录需要手动创建
配置tracker.conf
配置base_path=/home/yuqing/fastdfs(同样需要创建如已创建请忽略)
配置client.conf
配置base_path=/home/yuqing/fastdfs
配置tracker_server=172.16.36.245:22122
4.启动应用程序
启动tracker server
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
启动storage server
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
5.测试应用
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/1.jpg
当出现一下画面,便成功了
http://192.168.1.123/group1/M00/00/00/wKgBe1q0lTmAVUsKAATdp5YKaPM492_big.jpg
此时该地址是不能访问的需要配置nginx
6.安装nginx(准备)
安装SSL功能需要的openssl库插件
解压 tar -zxvf openssl-1.1.1-pre4.tar.gz
进入目录 cd openssl-1.1.1-pre4
执行以下操作 ./config make make install
安装pcre-8.39
cd pcre-8.39 执行以下操作 ./configure make sudo make install
安装zlib-1.2.11
cd zlib-1.2.11 执行以下操作 ./configure make sudo make install
注意 需要c++编译环境 yum install -y gcc gcc-c++
7.安装nginx
进入目录 cd nginx-1.13.11
执行以下操作 ./configure make sudo make install
修改目录权限
chmod a+rwx -R /usr/local/nginx/logs/
chmod a+rwx -R /usr/local/nginx/
检测配置文件是否正确
/usr/local/nginx/sbin/nginx -t 出现以下便成功了
启动nginx
/usr/local/nginx/sbin/nginx
访问192.168.1.123 默认80端口
8.安装fastdfs-nginx-module
减压 记住目录 unzip fastdfs-nginx-module-master.zip
9.进入nginx的安装包的源目录,然后编译和安装fastdfs-nginx-module
注意需要关闭所有nginx进程 pkill -9 nginx
进入nginx安装包解压目录
./configure --add-module=/home/sw/fastdfs-nginx-module-master/src(第8步目录)
执行以下命令安装 make make install
配置nginx.conf cd /usr/local/nginx/conf/ 编辑vi nginx.conf
location /group1/M00 {
root /home/yuqing/fastdfs/data;
ngx_fastdfs_module;
}
创建/M00软连接
ln -s /home/yuqing/fastdfs/data /home/yuqing/fastdfs/data/M00
修改mod_fastdfs.conf
更改tracker_server的IP
更改store_path0这个要与storaged的配置一致
复制 cp mod_fastdfs.conf /etc/fdfs/
复制 cp /home/sw/FastDFS/conf/http.conf /etc/fdfs/
cp /home/sw/FastDFS/conf/mime.types /etc/fdfs/
重新启动Nginx
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx
再次访问(便成功访问了)
http://192.168.1.123/group1/M00/00/00/wKgBe1q0lTmAVUsKAATdp5YKaPM492_big.jpg
相关安装包资料我已放在以下地址了,欢迎下载
https://download.csdn.net/download/notears0828/10329925
参考博客
https://blog.csdn.net/jun2016425/article/details/53572088