安装环境:
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. 【图像处理】Haar-like特征

    特征提取的原理.代码等: 如果是白黑白,是减去一个黑的还是2个黑的,网上有不同的说法:应该需要看原论文了. 论文原文 The sum of the pixels which lie within th ...

  2. Linux下你需要了解的10个网络和监控命令

    我下面列出来的10个基础的每个linux用户都应该知道的网络和监控命令.网络和监控命令类似于这些: hostname, ping, ifconfig, iwconfig, netstat, nsloo ...

  3. Hash表的平均查找长度ASL计算方法

    Hash表的“查找成功的ASL”和“查找不成功的ASL” ASL指的是 平均查找时间 关键字序列:(7.8.30.11.18.9.14) 散列函数: H(Key) = (key x 3) MOD 7 ...

  4. python lambda匿名函数

    Python的一个很重要的方面就是:函数式编程(functional programming),即可以再原本传递参数和值的地方传递函数. lambda x: x%3 == 0 和以下等价: def b ...

  5. WIFI_认证加密学习_STA_AP_WDS

    2-1.1_15_使用卡1_准备工作及配置内核====================================1.无线网卡连接上路由或AP之后使用上是和有线网卡是一样的,都是socket编程. ...

  6. POSIX 线程具体解释(3-相互排斥量:"固定加锁层次"/“试加锁-回退”)

    有时一个相互排斥量是不够的: 比方: 当多个线程同一时候訪问一个队列结构时,你须要2个相互排斥量,一个用来保护队列头,一个用来保护队列元素内的数据. 当为多线程建立一个树结构时.你可能须要为每一个节点 ...

  7. Tensoflw.js - 02 - 模型与内存管理(易懂)

    Tensoflw.js - 02 - 模型与内存管理(易懂) 参考 W3Cschool 文档:https://www.w3cschool.cn/tensorflowjs/ 本文主要翻译一些英文注释,添 ...

  8. Java中File常用的方法汇总

    创建:createNewFile()在指定位置创建一个空文件,成功就返回true,如果已存在就不创建,然后返回false.mkdir() 在指定位置创建一个单级文件夹.mkdirs() 在指定位置创建 ...

  9. 【转】每天一个linux命令(18):locate 命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/11/12/2765750.html locate 让使用者可以很快速的搜寻档案系统内是否有指定的档案.其 ...

  10. Promise 知识点

    .done() Promise 对象的回调链,不管以then方法或catch方法结尾,要是最后一个方法抛出错误,都有可能无法捕捉到(因为 Promise 内部的错误不会冒泡到全局).因此,我们可以提供 ...