安装环境:
1. CentOS-6.4-i386
2. FastDFS_v4.06
3. fastdfs-nginx-module_v1.15
4. Nginx-1.5.6(安装见此
5. libevent-2.0.21-stable

tracker server  IP:192.168.1.11
storage1 server IP:192.168.1.12 group1
storage2 server IP:192.168.1.13 group2
storage3 server IP:192.168.1.14 group2
 
1. CentOS系统初始化:
    #yum预装常用的服务器软件
      yum -y install gcc gcc-c++

2. 系统操作环境的设置
    #软件安装包存储
      /usr/local/src
    #libevent安装目录
      /usr/local/libevent
    #fastdfs安装目录
      /usr/local/fastdfs
    #nginx安装目录
      /usr/local/nginx
 
3. 安装libevent( fastdfs在编译源程序时fastdfs内部调用libevent的处理机制,,需要用到libevent一些依赖文件,否则编译fastdfs会出错)
    #卸载系统自带libevent,自带版本过低,安装fastdfs会出错
      1> rpm -qa|grep libevent
      2> yum remove libevent*
    #下载安装libevent:
      1> wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
      2> tar -zxvf libevent-2.0.21-stable.tar.gz
      3> cd libevent-2.0.21-stable
      4> ./configure --prefix=/usr/local/libevent
      5> make && make install
    #为libevent创建软链接到/lib库下,64位系统对应/lib64
      ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
      ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
 
4. 安装FastDFS
    1> wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz
    2> tar -zxvf FastDFS_v4.06.tar.gz
    3> cd FastDFS
    4> #由于定义/usr/local/fastdfs为fastdfs安装目录,所以需要修改make.sh
           vi make.sh
           #内容更改如下
           TARGET_PREFIX=/usr/local 修改为 /usr/local/fastdfs
           将/etc/fdfs 全部替换为 /usr/local/fastdfs/conf
    5> #安装
           ./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
           ./make.sh install
 
5. 配置Tracker
   #创建tracker目录保存运行日志
     mkdir -m 777 -p /home/fastdfs/tracker
   #修改tracker.conf配置
     vim /usr/local/fastdfs/conf/tracker.conf
     #修改内容如下所示

# the tracker server port
port=
# the base path to store data and log files
base_path=/home/yuqing/fastdfs -> base_path=/home/fastdfs/tracker #日志目录
#开启自定义server ID取代ip形式,方便内部网络服务器更换ip#**此方式要重点理解,.0以后新特性
use_storage_id = true #使用server ID作为storage server标识
storage_ids_filename = storage_ids.conf #<id> <group_name> <ip_or_hostname>
id_type_in_filename = id #文件名反解析中包含server ID,以前是ip

#移动storage_ids.conf文件
     cp -r /usr/local/src/FastDFS/conf/storage_ids.conf /usr/local/fastdfs/conf/
   #编辑storage服务器ID与IP地址的对应关系
     vim /usr/local/fastdfs/conf/storage_ids.conf
     #修改内容如下所示

#<id> <group_name> <ip_or_hostname>
group1 192.168.1.12
group2 192.168.1.13
group2 192.168.1.14

#编辑启动脚本
     vim /etc/init.d/fdfs_trackerd
     #启动脚本内容如下

#!/bin/bash
#
# fdfs_trackerd Starts fdfs_trackerd
#
#
# chkconfig:
# description: FastDFS tracker server
### BEGIN INIT INFO
# Provides: $fdfs_trackerd
### END INIT INFO
# Source function library.
. /etc/init.d/functions
FastDfs='/usr/local/fastdfs'
CONF="$FastDfs/conf/tracker.conf"
if [ ! -f $CONF ]; then
echo "file $CONF does not exist!"
exit
fi
PRG="$FastDfs/bin/fdfs_trackerd"
if [ ! -f $PRG ]; then
echo "file $PRG does not exist!"
exit
fi
Stop="$FastDfs/bin/stop.sh"
if [ ! -f $Stop ]; then
echo "file $Stop does not exist!"
exit
fi
Restart="$FastDfs/bin/restart.sh"
if [ ! -f $Restart ]; then
echo "file $Restart does not exist!"
exit
fi
RETVAL=
start() {
echo -n $"Starting FastDFS tracker server: "
$PRG $CONF &
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stop FastDFS tracker server: "
$Stop $PRG $CONF
RETVAL=$?
return $RETVAL
}
rhstatus() {
status fdfs_trackerd
}
restart() {
$Restart $PRG $CONF &
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rhstatus
;;
restart|reload)
restart
;;
condrestart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
exit
esac
exit $?

#给启动脚本增加权限
     chmod 777 /etc/init.d/fdfs_trackerd
   #启动tracker
     service fdfs_trackerd restart
   #启动成功,加入开机启动
     vim /etc/rc.d/rc.local
     #加入内容如下
     service fdfs_trackerd start
   #防火墙开启tracker端口22122
     vim /etc/sysconfig/iptables
     #加入内容如下
     -A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT
   #重启防火墙
     service iptables restart

6. 配置Storage
   #创建Storage目录保存运行日志及其data数据
     mkdir -m 777 -p /home/fastdfs/storage
   #修改storage.conf配置
     vim /usr/local/fastdfs/conf/storage.conf
   #修改内容如下所示

vim /usr/local/fastdfs/conf/storage.conf
# the name of the group this storage server belongs to
group_name=group1 #设置组名
# the name of the group this storage server belongs to
# the storage server port #the storage server port
port=
# the base path to store data and log files #日志目录
base_path=/home/yuqing/fastdfs -> /home/fastdfs/storage
# store_path#, based , if store_path0 not exists, it's value is base_path #data数据存储目录
# the paths must be exist
store_path0=/home/fastdfs/storage
# tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
tracker_server=192.168.209.121: ->192.168.1.11:

#编辑启动脚本
     vim /etc/init.d/fdfs_storaged
     #启动脚本内容如下

#!/bin/bash
#
# fdfs_storaged Starts fdfs_storaged
#
#
# chkconfig:
# description: FastDFS storage server
### BEGIN INIT INFO
# Provides: $fdfs_storaged
### END INIT INFO
# Source function library.
. /etc/init.d/functions
FastDfs='/usr/local/fastdfs'
CONF="$FastDfs/conf/storage.conf"
if [ ! -f $CONF ]; then
echo "file $CONF does not exist!"
exit
fi
PRG="$FastDfs/bin/fdfs_storaged"
if [ ! -f $PRG ]; then
echo "file $PRG does not exist!"
exit
fi
Stop="$FastDfs/bin/stop.sh"
if [ ! -f $Stop ]; then
echo "file $Stop does not exist!"
exit
fi
Restart="$FastDfs/bin/restart.sh"
if [ ! -f $Restart ]; then
echo "file $Restart does not exist!"
exit
fi
RETVAL=
start() {
echo -n $"Starting FastDFS storage server: "
$PRG $CONF &
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stop FastDFS storage server: "
$Stop $PRG $CONF
RETVAL=$?
return $RETVAL
}
rhstatus() {
status fdfs_storaged
}
restart() {
$Restart $PRG $CONF &
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rhstatus
;;
restart|reload)
restart
;;
condrestart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
exit
esac
exit $?

#给启动脚本增加权限
     chmod 777 /etc/init.d/fdfs_storaged
   #启动storage
     service fdfs_storaged restart
   #接下来会出现很多mkdir data path,这是系统在创建数据目录,如下图所示
   
   #启动成功,加入开机启动
     vim /etc/rc.d/rc.local
     #加入内容如下
     service fdfs_storaged start

7. 安装nginx(仅Storage)
    #创建nginx日志目录
      mkdir -m 777 -p /home/www/logs
    #安装nginx必需的库:zlib-devel openssl-devel pcre
      yum -y install zlib-devel openssl-devel
      #手动安装pcre
      1> wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
      2> tar -zxvf pcre-8.33.tar.gz
      3> cd pcre-8.33
      4> ./configure
      5> make && make install
      6> ln -s /usr/local/lib/libpcre.so.1 /lib
    #安装nginx
      1> wget http://nginx.org/download/nginx-1.5.6.tar.gz
      2> tar -zxvf nginx-1.5.6.tar.gz
      3> cd nginx-1.5.6
      4> ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
      5> make && make install
     #检查nginx配置是否正确
       /usr/local/nginx/sbin/nginx -t
     #出现以下类似信息表示配置正确
     
     #查看nginx编译选项
       /usr/local/nginx/sbin/nginx -V
     #编辑启动脚本
       vim /etc/init.d/fdfs_storaged
       #启动脚本内容如下

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/nginx.pid
# admin chenai
# Last Updated 20120.6. # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit #必填
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
#必填
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx start() {
[ -x $nginx ] || exit
[ -f $NGINX_CONF_FILE ] || exit
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
#service php-fpm start
[ $retval -eq ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
$nginx -s stop
echo_success
retval=$?
echo
#service php-fpm stop
[ $retval -eq ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
$nginx -s reload
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
version() {
$nginx -V
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null >&
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest|version)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest|version}"
exit
esac

#给启动脚本增加权限
       chmod 777 /etc/init.d/nginxd
     #启动nginx
       service nginxd restart
     #启动成功,加入开机启动
       vim /etc/rc.d/rc.local
       #加入内容如下
       service nginxd start

8. 安装nginx-module模块(仅Storage)
    1> wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz
    2> tar -zxvf fastdfs-nginx-module_v1.15.tar.gz;
    #修改插件配置文件
      vim /usr/local/src/fastdfs-nginx-module/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/fastdfs/include/fastdfs /usr/local/fastdfs/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/local/fastdfs/lib -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/usr/local/fastdfs/conf/mod_fastdfs.conf\"'"

#复制mod_fastdfs.conf到/usr/local/fastdfs/conf/目录下
      cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /usr/local/fastdfs/conf/
    #将/usr/local/fastdfs/lib 加入系统文件/etc/ld.so.conf中(编译时使用的动态链接库)
      vim /etc/ld.so.conf
      #修改内容如下
      /usr/local/fastdfs/lib
    #更新库文件缓存ld.so.cache
      /sbin/ldconfig
    #编译fastdfs-nginx-module模块
      1> cd nginx-1.1.19/
      2> ./configure 此处加上nginx之前的编译参数(使用 /usr/local/nginx/sbin/nginx -V 命令查看) --add-module=/usr/local/src/fastdfs-nginx-module/src
      3> make && make install
    #修改mod_fastdfs.conf配置
      vim /usr/local/fastdfs/conf/mod_fastdfs.conf
      #修改内容如下

# if load FastDFS parameters from tracker server
# since V1.
# default value is false
load_fdfs_parameters_from_tracker=true
# FastDFS tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=192.168.25.11:
# the port of the local storage server
# the default value is
storage_server_port=
# the group name of the local storage server
group_name=group1 #当前storage机器组名
# if the url / uri including the group name
# set to false when uri like /M00///xxx
# set to true when uri like ${group_name}/M00///xxx, such as group1/M00/xxx
# default value is false
url_have_group_name = true
# path(disk or mount point) count, default value is
# must same as storage.conf
store_path_count=
# store_path#, based , if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/home/fastdfs/storage
# set the log filename, such as /usr/local/apache2/logs/mod_fastdfs.log
# empty for output to stderr (apache and nginx error_log file)
log_filename=/home/www/logs/mod_fastdfs.log

#修改nginx.conf配置
      vim /usr/local/nginx/conf/nginx.conf
      #修改内容如下

worker_processes  ;
error_log /home/www/logs/error.log notice;
pid /home/www/logs/nginx.pid; worker_rlimit_nofile ;
events {
use epoll;
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream; sendfile on;
tcp_nopush on;
keepalive_timeout ;
tcp_nodelay on; server {
listen ;
server_name localhost;
location /组名/M00 {
alias /home/fastdfs/storage/data;
ngx_fastdfs_module;
}
}
}

#重启nginx服务
    service nginxd restart

9. 测试FastDFS

CentOS 6.4 i386 版本安装 FastDFS、使用Nginx作为文件访问WEB服务器的更多相关文章

  1. CentOS 6.5以上版本安装mysql 5.7 完整版教程(修订版)

    转载自:https://codeday.me/collect/20170524/21861.html 1: 检测系统是否自带安装mysql # yum list installed | grep my ...

  2. CentOS单机安装FastDFS&整合Nginx

    单机安装 一 准备工作 准备linux服务器或虚拟机,这里是虚拟机,操作系统CentOS 6.4 Tracker 和 Storage 安装在一台机器上 FastDFS 5.08版本 1,准备软件 软件 ...

  3. 在centos 5.5 i386 上安装 oracle 10g xe

    1.安装rpm包 nano /v.sh 将下面内容复制进去 #!/bin/bash rpm -Uvh compat-db-4.2.52-5.1.i386.rpm rpm -Uvh compat-lib ...

  4. centos 7 源码包安装、卸载nginx

    1.源码包安装之前,首页安装依赖包 yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre ...

  5. FastDFS 配置 Nginx 模块及访问测试

    #备注:以下nginx-1.10.3源码目录根据nginx版本号不同会有相应的变化,以nginx版本号为准#一.安装 Nginx 和 fastdfs-nginx-module1,安装 Nginx 请看 ...

  6. 【linux】linux 环境下 安装禅道(转载) -- 跟web服务器无关,无视apache、nginx!!!

    下载地址:http://www.zentao.net/download/zentao10.0.beta-80076.html 参考文章 链接 :https://blog.csdn.net/xinxin ...

  7. centos的6.9版本安装mysql

    用yum安装后,执行service命令启动: [root@centos ~]# yum install mysql-server Loaded plugins: fastestmirror, secu ...

  8. centos系统php5.6版本安装gd扩展库

    由于项目需要显示验证码登录系统,所以这里需要开启php的gd扩展 这边提供安装php5.6的yum方法扩展自选.# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fe ...

  9. CentOS中基于不同版本安装重复包的解决方案

    http://blog.chinaunix.net/uid-21710705-id-3039675.html

随机推荐

  1. 使用自己的域名解析cnblogs博客(CSDN也可以)

    本文主要介绍怎样使用自己购买的域名指向cnblogs博客 通常来说技术人员都会创建个自己的技术博客,总结下工作中的问题,经验等等,不过某些博客的访问链接的确是不太容易记忆或者输入,对我们分享造成一定的 ...

  2. JavaScript 之call , apply 和prototype 介绍

    1. 前言 为什么将这三个概念放在一起说.原因是这些是会在实现js 继承会需要使用到的 2. call 和 apply call 和 apply 的作用基本类似, 都是去执行function并将这个f ...

  3. POJ 3311 Hie with the Pie 先用floyd预处理,再状态压缩

    下面是别人的解题报告链接: http://blog.csdn.net/accry/article/details/6607703 下面是我的代码,我觉得链接中的代码有一点小问题,也许是我想错了吧. # ...

  4. 【知识笔记】Debugging

    一.启动调试出现 无法启动程序 当前状态中是非法 VS工具--选项--调试--常规--启用asp.net的JavaScript调试(chrome和ie)去掉勾选 二.web.config中<cu ...

  5. ACM常用算法

    数据结构 栈,队列,链表 哈希表,哈希数组 堆,优先队列 双端队列 可并堆 左偏堆 二叉查找树 Treap 伸展树 并查集 集合计数问题 二分图的识别 平衡二叉树 二叉排序树 线段树 一维线段树 二维 ...

  6. JNI学习笔记_C调用Java

    一.笔记 1.C调用Java中的方法,参考jni.pdf pg97可以参考博文:http://blog.csdn.net/lhzjj/article/details/26470999步骤: a. 创建 ...

  7. dgraph 数据加载

    dgraph 可以方便的进行大量的数据加载 下载rdf 文件 wget "https://github.com/dgraph-io/tutorial/blob/master/resource ...

  8. 【转】linux下解压.bz2压缩文件

    原文网址:http://zhidao.baidu.com/question/90378903.html tar-c: 建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压 ...

  9. Apache关闭VirtualHost的Log日志记录

    有时我们的apache产生的日志是超大的并且 没什么用处,这时我们就可以关闭了,关闭apache日志很简单,直接ErrorLog off或 # CustomLog即可. Web server(ex: ...

  10. bzoj 3611(洛谷 4103) [Heoi2014]大工程——虚树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3611 https://www.luogu.org/problemnew/show/P4103 ...