#!/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 /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目录的软连接
# 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