CentOS 6.4 i386 版本安装 FastDFS、使用Nginx作为文件访问WEB服务器
安装环境:
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
#yum预装常用的服务器软件
yum -y install gcc gcc-c++
#软件安装包存储
/usr/local/src
#libevent安装目录
/usr/local/libevent
/usr/local/fastdfs
#nginx安装目录
/usr/local/nginx
#卸载系统自带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
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
#内容更改如下
将/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
#创建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
#创建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服务器的更多相关文章
- CentOS 6.5以上版本安装mysql 5.7 完整版教程(修订版)
转载自:https://codeday.me/collect/20170524/21861.html 1: 检测系统是否自带安装mysql # yum list installed | grep my ...
- CentOS单机安装FastDFS&整合Nginx
单机安装 一 准备工作 准备linux服务器或虚拟机,这里是虚拟机,操作系统CentOS 6.4 Tracker 和 Storage 安装在一台机器上 FastDFS 5.08版本 1,准备软件 软件 ...
- 在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 ...
- centos 7 源码包安装、卸载nginx
1.源码包安装之前,首页安装依赖包 yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre ...
- FastDFS 配置 Nginx 模块及访问测试
#备注:以下nginx-1.10.3源码目录根据nginx版本号不同会有相应的变化,以nginx版本号为准#一.安装 Nginx 和 fastdfs-nginx-module1,安装 Nginx 请看 ...
- 【linux】linux 环境下 安装禅道(转载) -- 跟web服务器无关,无视apache、nginx!!!
下载地址:http://www.zentao.net/download/zentao10.0.beta-80076.html 参考文章 链接 :https://blog.csdn.net/xinxin ...
- centos的6.9版本安装mysql
用yum安装后,执行service命令启动: [root@centos ~]# yum install mysql-server Loaded plugins: fastestmirror, secu ...
- centos系统php5.6版本安装gd扩展库
由于项目需要显示验证码登录系统,所以这里需要开启php的gd扩展 这边提供安装php5.6的yum方法扩展自选.# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fe ...
- CentOS中基于不同版本安装重复包的解决方案
http://blog.chinaunix.net/uid-21710705-id-3039675.html
随机推荐
- iOS-----使用NSURLConnection
使用NSURLConnection 如果只是为了读取HTTP等服务器数据,或向服务器提交数据,iOS还提供了NSURLConnection类,NSURLConnection使用NSURLRequest ...
- 【机器学习算法】bagging算法
参考 1.AdaBoost从原理到实现: 完
- 从 0 到 1 合理高效使用 GitHub 的资料
来自:https://github.com/xirong/my-git/blob/master/how-to-use-github.md 说明 作为一名开发者,Github上面有很多东西值得关注学习, ...
- 51Nod:1995 三子棋
1995 三子棋 题目来源: syu校赛 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 小的时候大家一定玩过"井"字棋吧.也就是在 ...
- 【idea】如何将idea的项目路径设置成代码目录和配置文件目录
一:创建相应的目录 二.提升目录的等级
- css中display为none 和visibility为hidden的区别
区别一: display:none Turns off the display of an element (it has no effect on layout); all child eleme ...
- hibernate 1-1(具体解释)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qilixiang012/article/details/27870343 域模型 关系数据模型: 依 ...
- nyoj 魔法少女
魔法少女 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 前些时间虚渊玄的巨献小圆着实火了一把. 在黑长直(小炎)往上爬楼去对抗魔女之夜时,她遇到了一个问题想请你帮忙. 因为 ...
- 【转】每天一个linux命令(7):mv命令
原文网址:http://www.cnblogs.com/peida/archive/2012/10/27/2743022.html mv命令是move的缩写,可以用来移动文件或者将文件改名(move ...
- centos7虚拟机安装出现license information
问题:vm 10下安装CentOs7后无法启动.出现一个license information页面 解决办法:出现license information,即说明需要同意许可信息,输入1-回车-2-回车 ...