在制作网站、小程序或者APP时,肯定离不开图片的,那么这些图片存放在什么位置?怎么存放?又如何展示呢,那么,这篇文章手把手带你搭建一台属于自己的图片服务器。
话不多说,上号,不对,是上代码:
所需工具:Linux系统+FastDFS+Nginx
1.依赖环境下载
系统: vagrant(centos7)
-
yum install -y gcc-c++ #需要依赖gcc
-
yum install -y pcre #用于支持rewrite模块 pcre-8.32-17
-
yum install -y libevent #FastDFS依赖libevent库 libevent-2.0.21-4.el7.x86_64
-
yum install -y zlib zlib-devel #用于支持gzip模块 zlib-1.2.7-17.el7.x86_64
-
libfastcommon-master.zip #libfastcommon包含了FastDFS运行所需要的一些基础库https://github.com/happyfish100/libfastcommon/releases
-
fastdfs-nginx-module-master.zip # https://codeload.github.com/happyfish100/fastdfs-nginx-module/zip/master
-
FastDFS版本:fastdfs-5.11.zip #https://github.com/happyfish100/fastdfs/archive/V5.11.zip
-
Nginx版本:nginx-1.14.tar.gz : #官网下载: http://nginx.org/en/download.html
2.安装libfastcommon
unzip libfastcommon-1.0.39.zip
mv libfastcommon-1.0.39 /usr/local/libfastcommon
cd /usr/local/libfastcommon/
./make.sh #编译
./make.sh install #安装
# 检查确认/usr/lib64 和 /usr/lib 目录下都生成了 libfastcommon.so (有些版本可能/usr/lib下不会生成)
ls /usr/lib64 | grep libfastcommon.so
ls /usr/lib | grep libfastcommon.so
3.安装tracker
cd /download
unzip fastdfs-5.11.zip
mv fastdfs-5.11 /usr/local/FastDFS
cd /usr/local/FastDFS/
./make.sh && ./make.sh install #编译之后接着进行安装
#确认安装成功,没有报错后,拷贝配置文件到/etc/fdfs
cp /usr/local/FastDFS/conf/* /etc/fdfs/
#,进入/etc/fdfs 目录, 如果没有tracker.conf就拷贝一份tracker.conf.sample 去掉sample
cp tr