FastDFS+Nginx 集成并实现断点续传(二)

1.5 安装配置Nginx

      这一步非常重要, 需要安装Nginx并给Nginx安装fastdfs-nginx-module模块,以便支持下载和断点续传功能。具体步骤:

      执行nginx_install_1.4.2.sh脚本,脚本内容:

#!/bin/bash
BUILD_DIR="/data/soft"
INSTALL_DIR="/usr/local/nginx"

cd $BUILD_DIR
tar zxvf fastdfs-nginx-module_v1.15.tar.gz
echo "------------- install pcre -------------"
tar xzf pcre-8.33.tar.gz
echo "----------------- install nginx -------------"
tar xzf nginx-1.4.2.tar.gz

cd nginx-1.4.2

./configure --prefix=$INSTALL_DIR --with-pcre=$BUILD_DIR/pcre-8.33 --add-module=$BUILD_DIR/fastdfs-nginx-module/src

make
make install

 在nginx的server配置段中增加M00的location声明:

# vi /usr/local/nginx/conf/nginx.conf

location /group1/M00 {
            root /home/storage/fastdfs/data;
            ngx_fastdfs_module;
    }

# :wq

 

 

1.6 安装配置storage.conf

      具体步骤:

 

# vi /etc/fdfs/storage.conf

# HTTP settings
# 关闭内置的web server
http.disabled=true

# the port of the web server on this storage server
# web server的端口改成80
http.server_port=80

# the name of the group this storage server belongs to
# 此台storage1所属的服务器组名,同组内storage数据完全相同
group_name=group1

# the base path to store data and log files
# 放置data和log的目录
base_path=/home/storage/fastdfs
   
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# 放置文件的目录
store_path0=/home/storage/fastdfs

# tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
# tracker server的ip和端口,此处可以写多个tracker server,每行一个
tracker_server=10.10.208.98:22122
tracker_server=10.10.208.76:22122

# :wq
 

       

 

1.5 安装配置mod_fastdfs.conf

      具体步骤:

# cp /data/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
# vi /etc/fdfs/mod_fastdfs.conf

# the base path to store log files
# 放置log的目录
base_path=/home/storage/fastdfs

# FastDFS tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
# tracker1的ip和端口,此处可以写多个tracker server,每行一个
tracker_server=10.10.208.98:22122
tracker_server=10.10.208.76:22122

# the group name of storage server
# 此台storage server所属的服务器组名
group_name=group1
 
# if uri including group name
# default value is false
# 在URL中包含group名称
url_have_group_name = true

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# 放置文件的目录
store_path0=/home/storage/fastdfs

#:wq
# mkdir -p /home/storage/fastdfs

 创建M00目录的软连接

# ln -s /home/storage/fastdfs/data  /home/storage/fastdfs/data/M00

 启动storage服务

# service fdfs_storaged start

 启动nginx,启动之前,要确定fdfs_trackerd服务已启动且相关防火墙端口已开放

# /usr/local/nginx/sbin/nginx

 确认80,23000端口已经监听

netstat -ntl

 

 

 

1.7 在tracker上的操作[作为client测试]

# vim /etc/fdfs/client.conf
    # the base path to store log files
    base_path=/tmp
    
    # tracker_server can ocur more than once, and tracker_server format is
    #  "host:port", host can be hostname or ip address
    tracker_server=10.10.208.98:22122
    tracker_server=10.10.208.76:22122
# :wq

 创建一个用于测试的文件test.txt

# vi test.txt

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

# :wq 
# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload test.txt

 


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

http://10.10.208.76/group1/M00/00/01/CgrQTFIAhcSjKj9YAAAAJr0uFFY988_big.txt

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

 

常用命令:

#重启tracker
# service fdfs_trackerd restart

#重启storage
# service fdfs_storaged restart

#启动nginx
# /usr/local/nginx/sbin/nginx

#kill nginx进程
# pkill -9 nginx

#监测storage状态
# /usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf

 
 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值