fastdfs5.0.5+nginx安装+tracker+storage

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

一、为了顺利安装能够先将防火墙关掉linux

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

二、增长gcc gcc-c++nginx

yum install -y gcc gcc-c++

三、安装libfastcommon 
解压:将安装包解压。c++

unzip libfastcommon-1.0.7.zipcd libfastcommon
./make.sh./make.sh install

能够看到libfastcommon.so安装到了/usr/lib64/libfastcommon.so 
可是FastDFS主程序设置的lib目录是/usr/local/lib 
四、建立软连接centos

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

五、安装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

六、配置Tracker服务器

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

运行app

fdfs_trackerd /etc/fdfs/tracker.conf

七、配置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

运行this

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

八、安装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\"'"

九、配置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

十、测试

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.06Copyright (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=0tracker_query_storage_store_list_without_group:
        server 1. group_name=group1, ip_addr=192.168.68.114, port=23000group_name=group1, ip_addr=192.168.0.62, port=23000storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txtsource ip address: 192.168.0.62file timestamp=2012-06-13 17:58:25file size=37file crc32=3584975788file url: http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txtstorage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txtsource ip address: 192.168.68.114file timestamp=2012-06-13 17:58:25file size=37file crc32=3584975788file 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

若是看到文件内容,说明配置成功!

相关文章
相关标签/搜索