fastdfs5.0.5+nginx安装+tracker+storage

服务器环境:centos6
IP:192.168.0.62
所需资源下载:http://pan.baidu.com/s/1pwOQa 密码:q63k

1、为了顺利安装可以先将防火墙关掉

service iptables stop 
chkconfig iptables off
vi /etc/selinux/config
修改 selinux=disable

2、增加gcc gcc-c++

yum install -y gcc gcc-c++

3、安装libfastcommon
解压:将安装包解压。

unzip libfastcommon-1.0.7.zip
cd libfastcommon
./make.sh
./make.sh install

可以看到libfastcommon.so安装到了/usr/lib64/libfastcommon.so
但是FastDFS主程序设置的lib目录是/usr/local/lib
4、创建软链接

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 

5、安装FastDFS
解压FastDFS

tar -zxvf FastDFS_v5.05.tar.gz 
cd FastDFS
vi ./make.sh
TARGET_CONF_PATH=/usr/local/FastDFS
./make.sh
./make.sh install
cp /ust/local/FastDFS/tracker.conf.sample /etc/fdfs/tracker.conf
cp /ust/local/FastDFS/storage.conf.sample /etc/fdfs/storage.conf

6、配置Tracker

mkdir /data/fastdfs_tracker
vi /etc/fdfs/tracker.conf
base_path=/data/fastdfs_tracker

运行

fdfs_trackerd /etc/fdfs/tracker.conf

7、配置Storage

mkdir /data/fastdfs_storage_info
mkdir /data/fastdfs_storage_data
vi /etc/fdfs/storage.conf
base_path=/data/fastdfs_storage_info
store_path0=/data/fastdfs_storage_data
tracker_server=192.168.0.62:22122

运行

fdfs_storaged /etc/fdfs/storage.conf

配置完成,可以在如下目录查看日志

/data/fastdfs_tracker/logs/tracker.log
/data/fastdfs_storage_info/logs/storage.log

启动tracker

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

8、安装nginx
安装nginx依赖包

yum install –y openssl-devel pcre-devel zlib-devel

解压fastdfs-nginx-module

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz 
cd fastdfs-nginx-module
cp ./fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf

修改如下信息

tracker_server=192.168.1.50:22122
url_have_group_name= true
store_path0=/data/fastdfs_storage_data

解压、安装nginx

tar -zxvf nginx-1.7.8.tar.gz
cd nginx-1.7.8
./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src
make 
make install

如果make的时候报错做如下操作
a、yum groupinstall “Development Tools”
b、修改 fastdfs-nginx-module_v1.15/src/config

vi fastdfs-nginx-module_v1.15/src/config
修改成以下内容 
ngx_addon_name=ngx_http_fastdfs_module 
HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module" 
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c" 
CORE_INCS="$CORE_INCS /usr/local/fdfs/include/fastdfs /usr/local/fdfs/include/fastcommon/" 
CORE_LIBS="$CORE_LIBS -L/usr/local/fdfs/lib -lfastcommon -lfdfsclient" 
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/usr/local/fdfs/conf/mod_fastdfs.conf\"'" 

9、配置nginx

vi /usr/local/nginx/conf/nginx.conf
location /group1/M00 {
            root /data/fastdfs_storage_data;
            ngx_fastdfs_module;
}
location / {
    if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
        add_header Content-Disposition: 'attachment;';
    }
}

运行

ldd $(which /usr/local/nginx/sbin/nginx)

Tracker server启动

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

Storage server启动

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

查看是否启动成功

netstat -ntpl | grep fdfs

启动nginx
首先拷贝FastDFS目录下conf目录下得http.conf,mime.types

cp http.conf mime.types /etc/fdfs/
cd /usr/loca/nginx/sbin
./nginx

10、测试

cp /ust/local/FastDFS/client.conf.sample /etc/fdfs/client.conf
vi /etc/fdfs/client.cof
base_path=/tmp
tracker_server=192.168.0.62:22122

创建测试文件

vi test.txt

输入内容: hello,this is my first fastdfs test
运行

 /usr/bin/fdfs_test /etc/fdfs/client.conf upload test.txt

打印如下内容,说明上传成功

This is FastDFS client test program v3.06


Copyright (C) 2008, Happy Fish / YuQing


FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.


[2012-06-13 17:58:25] INFO - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key 


length=0


tracker_query_storage_store_list_without_group:
        server 1. group_name=group1, ip_addr=192.168.68.114, port=23000


group_name=group1, ip_addr=192.168.0.62, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txt
source ip address: 192.168.0.62
file timestamp=2012-06-13 17:58:25
file size=37
file crc32=3584975788
file url: http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt
source ip address: 192.168.68.114
file timestamp=2012-06-13 17:58:25
file size=37
file crc32=3584975788
file url: http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt

使用浏览器打开上传的文件

http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt

如果看到文件内容,说明配置成功!

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值