首先需要在ubuntu上下载好文件资源,一共是三个资源,在下载资源之前建议将git和nginx安装好,在本教程中将会用到。
(ngnix:http://nginx.org/download/nginx-1.12.2.tar.gz,利用winscp上传压缩文件,然后利用tar口令解压nginx:tar -zxvf /home/ubuntu/source/nginx-1.12.2.tar.gz)
libfastcommon
https://github.com/happyfish100/libfastcommon/tree/V1.0.36
fastdfs
https://github.com/happyfish100/fastdfs/tree/V5.11
fastdfs-nginx-module
https://github.com/happyfish100/fastdfs-nginx-module
下载完毕我们就开始搭建了。
编译安装 libfastcommon
> ./make.sh
> ./make.sh install
> ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
编译安装 fastdfs
> ./make.sh
> ./make.sh install
配置tracker.conf
> cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
> vi /etc/fdfs/tracker.conf
修改内容:
base_path=/home/fastdfs
配置storage.conf
> cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
> vi /etc/fdfs/storage.conf
修改内容:
> base_path=/home/fastdfs
> tracker_server=10.0.2.15:22122
> store_path0=/home/fastdfs
配置 http.conf mime.types
> cp fastdfs-5.11/conf/http.conf /etc/fdfs/
> cp fastdfs-5.11/conf/mime.types /etc/fdfs/
配置client.conf
> cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
> vi /etc/fdfs/client.conf
修改内容:
> base_path=/home/fastdfs
> tracker_server=10.0.2.15:22122
> include http.conf #打开该行代码 默认是注释掉的
启动tracker
> /etc/init.d/fdfs_trackerd start
其他命令:
/etc/init.d/fdfs_trackerd stop #停止
/etc/init.d/fdfs_trackerd restart #重启
启动storage
> /etc/init.d/fdfs_storaged start
其他命令 :
/etc/init.d/fdfs_storaged stop #停止
/etc/init.d/fdfs_storaged restart #重启
测试fastdfs安装情况
fdfs_test /etc/fdfs/client.conf upload /home/0.gif
如图,生成了上传图片的地址。