yum -y groupinstall 'Development Tools'
yum -y install wget
2.下载安装libfastcommon
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon/
./make.sh
./make.sh install
3.下载安装fastdfs
https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
tar -zxvf V5.05.tar.gz
cd fastdfs-5.05/
./make.sh
./make.sh install
4.修改配置文件
-data
-fdfs
-tracker
-storage
-client
5.配置tracker
cd /etc/fdfs
mv tracker.conf.sample tracker.conf
vi tracker.conf
//...
base_path=/data/fdfs/tracker
//...
配置storage
cd /etc/fdfs
mv storage.conf.sample storage.conf
vi storage.conf
//...
base_path=/data/fdfs/storage #指定日志位置
store_path0=/data/fdfs/storage #指定数据位置
tracker_server=192.168.153.130:22122 #指定tracker服务器地址
//...
配置client
cd /etc/fdfs
mv client.conf.sample client.conf
vi client.conf
//...
base_path=/data/fdfs/client
tracker_server=192.168.153.130:22122
//...
6.启动tracker和storage
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
7.测试
#上传
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/lily/a.txt
#下载
/usr/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKiZglauvkmANC2wAAAAPpWmuhI171.txt
#删除
/usr/bin/fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKiZglauvkmANC2wAAAAPpWmuhI171.txt
安装Nginx+fastdfs-nginx-module
1. 下载nginx和fastdfs-nginx-module的安装包
tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1
./configure --prefix=/usr/local/nginx (--prefix是安装到那个目录下)
make
make install
2.安装完nginx后进行nginx的配置
cd /usr/local/nginx/conf
vi nginx.conf //这里编辑的是安装目录中的配置文件
3.在server节点加入下面的配置
location /group1/M00{
root /data/fdfs/storage/data; //该路径是真正储存图片的路径
ngx_fastdfs_module;
}
4.安装和配置nginx插件fastdfs-nginx-module
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
cd fastdfs-nginx-module/src/
vi config (
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient")//修改配置文件里的东西和括号里的一样,不然编译的时候会保存
5.接着需要将插件添加到nginx
cd /root/nginx-1.10.1/
./configure --add-module=/root/fastdfs-nginx-module/src/ //将文件上传模块增减到nginx中
make
make install
6.拷贝并修改fastdfs-nginx-module的配置文件
cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
vim 修改/etc/fdfs/mod_fastdfs.conf 保存退出
修改如下几项:
tracker_server=192.168.1.188:22122
store_path0=/data/fastdfs/storage
base_path=/data/fastdfs/storage/data
url_have_group_name = true(配置多个tracker时,应该将此项设置为true)
建立软连接(配置文件中storage存放数据的路径)
ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/M00
将FastDFS_v4.06配置目录下的2个文件复制到/etc/fdfs目录下:
cp /usr/local/fastdfs-5.05/conf/http.conf .
cp /usr/local/fastdfs-5.05/conf/mime.types .
最后:
// 启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
//启动fdfs
/usr/bin/fdfs_trackerd /usr/soft/fastdfs-5.05/conf/tracker.conf start
/usr/bin/fdfs_storaged /usr/soft/fastdfs-5.05/conf/storage.conf start
测试上传下载