1、软件 下载:
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
wget http://nginx.org/download/nginx-1.8.0.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
2、libfastcommon安装:
cp V1.0.7.tar.gz /usr/local/
tar -zxvf V1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install
libfastcommon.so默认安装到了/usr/lib64/libfastcommon.so,而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
3、安装FastDFS:
(1)tar -zxvf V5.05.tar.gz -C /usr/local
cd /usr/local/fastdfs-5.05/
./make.sh
./make.sh install
cd /etc/fdfs
(2)配置文件设置:
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf
详细设置见附件
tracker.conf配置中要修改的几个项:
bind_addr=自己的ip(外网)
port=22122
http.server_port=8080
storage.conf配置中要修改的几个项:
group_name=group1
bind_addr=自己的ip(外网)
port=23000
base_path=/usr/local/fastdfs
store_path0=/usr/local/fastdfs
tracker_server=自己的ip(外网):22122
http.server_port=8888
(3)启动
启动tracker storage.conf
fdfs_trackerd /etc/fdfs/tracker.conf
fdfs_storaged /etc/fdfs/storage.conf
4、安装nginx插件:
(1)安装
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
cd fastdfs-nginx-module/src/
(2)config文件修改:
vi config
修改如下配置,我这里原来是
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
改成
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
这个是很重要的,不然在nginx编译的时候会报错的,我看网上很多在安装nginx的fastdfs的插件报错,都是这个原因,而不是版本不匹配。
cp mod_fastdfs.conf /etc/fdfs
修改配置
group_name=group1
tracker_server=自己的ip(外网):22122
store_path0=/usr/local/fastdfs
base_path=/usr/local/fastdfs
url_have_group_name = true
2)、配置文件服务器的软连接
ln -s /usr/local/fastdfs/data /usr/local/fastdfs/data/M00 (配置文件中stoage存放数据的路径)
同时将以下两个文件复制到/etc/fdfs/
cp /usr/local/fastdfs-5.05/http.conf /etc/fdfs/
cp /usr/local/fastdfs-5.05/mime.types /etc/fdfs/
5、nginx安装:
在每个Storage服务器上安装Nginx
(1)pcre安装:
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make && make install
cd ../
ln -s /usr/local/lib/libpcre.so.1 /lib64/
(2)zlib安装:
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make && make install
cd ../
(3)nginx安装:
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx-1.8.0 --add-module=/usr/local//fastdfs-nginx-module/src
make
make install
cd /usr/local/nginx/conf
vi nginx.conf
在server中添加
location /group1/M00{
root /usrdata/fastdfs/data;
ngx_fastdfs_module;
}
启动:
/usr/local/nginx/sbin/nginx
安装完成。
附带一个nginx的启动与停止:
【linux中安装FastDFS-v5.05+nginx-1.8.0】
nginx -s reload:修改配置后重新加载生效 nginx -s reopen:重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
关闭nginx:
nginx -s stop:快速停止nginx
quit:完整有序的停止nginx
其他的停止nginx 方式:
ps -ef | grep nginx
kill -QUIT 主进程号:从容停止Nginx
kill -TERM 主进程号:快速停止Nginx
pkill -9 nginx:强制停止Nginx
启动nginx:
nginx -c /path/to/nginx.conf
平滑重启nginx:
kill -HUP 主进程号
6、测试文件上传:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload 1.jpg(自己找一个图片测试)
根据提示访问文件