FastDFS整合nginx(三)

一 安装

百度云:所有附件的地址

unzip fastdfs-nginx-module-master.zip

[root@node02 mnt]# cd fastdfs-nginx-module-master/
[[email protected] fastdfs-nginx-module-master]# ll
总用量 8
-rw-r--r-- 1 root root 2804 5月  30 2017 HISTORY
-rw-r--r-- 1 root root 1722 5月  30 2017 INSTALL
drwxr-xr-x 2 root root  109 5月  30 2017 src
[root@node02 fastdfs-nginx-module-master]#?

安装nginx

(1)安装pcre依赖 第一步联网下载pcre压缩文件依赖 wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz

drwxr-xr-x  9 es   es         186 10月  4 21:41 nginx-1.12.2
-rw-r--r--  1 root root    981687 10月  4 20:30 nginx-1.12.2.tar.gz
drwxr-xr-x  9 1169 1169     12288 10月  4 21:40 pcre-8.37
-rw-r--r--  1 root root   2041593 10月  4 20:30 pcre-8.37.tar.gz
第二步解压压缩文件
tar -zvxf fpcre-8.37.tar.gz

第三步./configure完成后,回到pcre目录下执行make,最后执行make install

(2)安装openssl、zlib、gcc依赖

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

(3) 其中--prefix是指定nginx安装路径,--add-module指定fastDFS的nginx模块的源代码路径

./configure --prefix=/usr/local/nginx_fdfs --add-module=/mnt/fastdfs-nginx-module-master/src

(4)安装nginx 使用命令解压

  • make && make install

注:以上安装Nginx的FastDFS扩展模块注意事项(也可以这样安装)

我们知道,Nginx的安装需要Linux安装相关的几个库,否则编译会出现错误,这几个库分别是:1、gcc编译器是否安装?   检查是否安装:yum list installed | grep gcc   执行安装:yum install gcc -y2、openssl库是否安装?   检查是否安装:yum list installed | grep openssl   执行安装:yum install openssl openssl-devel -y3、pcre库是否安装?   检查是否安装:yum list installed | grep pcre   执行安装:yum install pcre pcre-devel -y4、zlib库是否安装?   检查是否安装:yum list installed | grep zlib   执行安装:yum install zlib zlib-devel -yyum install gcc openssl openssl-devel pcre pcre-devel zlib zlib-devel -y

二 配置

1、将/mnt/fastdfs-nginx-module-master/src目录下的mod_fastdfs.conf文件拷贝到 /etc/fdfs/目录下,这样才能正常启动Nginx;

2、修改mod_fastdfs.conf配置文件:

base_path=/opt/fastdfs/nginx_mod
tracker_server=192.168.180.104:22122
store_path0=/opt/fastdfs/storage/files
url_have_group_name = true

3、配置Nginx的配置文件

#拦截请求路径中包含 /group[1-9]/M0[0-9] 的请求,使用 fastdfs的Nginx 模块进行转发:
location ~ /group[1-9]/M0[0-9] {
     ngx_fastdfs_module;
}

注:如果出现404访问不到,检查一下 url_have_group_name = false

[[email protected] fdfs]# cat mod_fastdfs.conf
# connect timeout in seconds
# default value is 30s
connect_timeout=2
?
# network recv and send timeout in seconds
# default value is 30s
network_timeout=30
?
# the base path to store log files
base_path=/opt/fastdfs/nginx_mod
?
# if load FastDFS parameters from tracker server
# since V1.12
# default value is false
load_fdfs_parameters_from_tracker=true
?
# storage sync file max delay seconds
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.12
# default value is 86400 seconds (one day)
storage_sync_file_max_delay = 86400
?
# if use storage ID instead of IP address
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# default value is false
# since V1.13
use_storage_id = false
?
# specify storage ids filename, can use relative or absolute path
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.13
storage_ids_filename = storage_ids.conf
?
# 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.180.104:22122
?
# the port of the local storage server
# the default value is 23000
storage_server_port=23000
?
# the group name of the local storage server
group_name=group1
?
# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
url_have_group_name = true
?
# path(disk or mount point) count, default value is 1
# must same as storage.conf
store_path_count=1
?
# store_path#, based 0, if store_path0 not exists, it‘s value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/opt/fastdfs/storage/files
#store_path1=/home/yuqing/fastdfs1
?
# standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info
?
# 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=
?
# response mode when the file not exist in the local file system
## proxy: get the content from other storage server, then send to client
## redirect: redirect to the original storage server (HTTP Header is Location)
response_mode=proxy
?
# the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
# multi aliases split by comma. empty value means auto set by OS type
# this paramter used to get all ip address of the local host
# default values is empty
if_alias_prefix=
?
# use "#include" directive to include HTTP config file
# NOTE: #include is an include directive, do NOT remove the # before include
#include http.conf
?
?
# if support flv
# default value is false
# since v1.15
flv_support = true
?
# flv file extension name
# default value is flv
# since v1.15
flv_extension = flv
?
?
# set the group count
# set to none zero to support multi-group on this storage server
# set to 0  for single group only
# groups settings section as [group1], [group2], ..., [groupN]
# default value is 0
# since v1.14
group_count = 0
?
# group settings for group #1
# since v1.14
# when support multi-group on this storage server, uncomment following section
#[group1]
#group_name=group1
#storage_server_port=23000
#store_path_count=2
#store_path0=/home/yuqing/fastdfs
#store_path1=/home/yuqing/fastdfs1
?
# group settings for group #2
# since v1.14
# when support multi-group, uncomment following section as neccessary
#[group2]
#group_name=group2
#storage_server_port=23000
#store_path_count=1
#store_path0=/home/yuqing/fastdfs
?
[root@node02 fdfs]#
?
三 启动与测试
1、启动带有fastdfs模块的Nginx

2、重启fastDFS服务进程,执行如下命令: fdfs_trackerd /etc/fdfs/tracker.conf restart fdfs_storaged /etc/fdfs/storage.conf restart

3、上传一个文件进行测试验证:

fdfs_test /etc/fdfs/client.conf upload /root/aa.txt

4、在浏览器访问上传的文件

[root@node02 conf]# /usr/local/nginx_fdfs/sbin/nginx -c  /usr/local/nginx_fdfs/conf/nginx.conf -t
ngx_http_fastdfs_set pid=5196
nginx: the configuration file /usr/local/nginx_fdfs/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx_fdfs/conf/nginx.conf test is successful
[root@node02 conf]#
[[email protected] conf]# /usr/local/nginx_fdfs/sbin/nginx -c  /usr/local/nginx_fdfs/conf/nginx.conf
ngx_http_fastdfs_set pid=5205
[root@node02 conf]#
[[email protected] ~]# cp anaconda-ks.cfg aa.txt
[[email protected] ~]# fdfs_test /etc/fdfs/client.conf upload /root/aa.txt
This is FastDFS client test program v5.11
?
Copyright (C) 2008, Happy Fish / YuQing
?
FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.
?
[2019-11-09 13:47:00] DEBUG - base_path=/opt/fastdfs/client, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0
?
tracker_query_storage_store_list_without_group:
        server 1. group_name=, ip_addr=192.168.180.104, port=23000
?
group_name=group1, ip_addr=192.168.180.104, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111.txt
source ip address: 192.168.180.104
file timestamp=2019-11-09 13:47:00
file size=1731
file crc32=1006568792
example file url: http://192.168.180.104/group1/M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111_big.txt
source ip address: 192.168.180.104
file timestamp=2019-11-09 13:47:00
file size=1731
file crc32=1006568792
example file url: http://192.168.180.104/group1/M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111_big.txt
[root@node02 ~]#

原文地址:https://www.cnblogs.com/dalianpai/p/11832217.html

时间: 2024-10-12 03:08:37

FastDFS整合nginx(三)的相关文章

FastDFS整合nginx后,nginx一直报错

FastDFS整合nginx后,nginx一直报错: 报错内容: [2018-06-11 09:41:21] ERROR - file: ../common/fdfs_http_shared.c, line: 148, param "http.mime_types_filename" not exist or is empty 处理过程: #include http.conf是写在/etc/fdfs/mod_fastdfs.conf里,然而在 /etc/fdfs目录中没有 http.c

CentOS单机安装FastDFS&整合Nginx

单机安装 一 准备工作 准备linux服务器或虚拟机,这里是虚拟机,操作系统CentOS 6.4 Tracker 和 Storage 安装在一台机器上 FastDFS 5.08版本 1,准备软件 软件下载:http://sourceforge.net/projects/fastdfs/files/               文中用到的 https://pan.baidu.com/s/1IeZqzt6Gc5Yc34RMwew3nQ     提取码:7dvf  2,安装gcc FastDFS是C语

FastDFS整合Nginx的模块:fastdfs-nginx-module报错:fdfs_define.h:15:27: 致命错误:common_define.h:没有那个文件或目录

错误提示: /usr/include/fastdfs/fdfs_define.h:15:27: 致命错误:common_define.h:没有那个文件或目录 [解决办法] 1.编辑fastdfs-nginx-module的配置文件 vim /home/zsd/fast/fastdfs-nginx-module-1.20/src/config 2.将原文修改为上图的两处红框圈出的地方 ngx_module_incs="/usr/local/include /usr/include/fastcomm

FastDFS 和nginx整合

失败的经历:     从昨晚到今晚,一直在配置这FastDFS 和nginx整合这两个东西.听了黑马的讲师说一个人第一次做这个,光是搭建一个最简单的分布式文件系统至少需要1天时间.其实看来,果然没错.不过大部分时间都花在了执行错误的方法上面. 可能有人是看过了传智播客的讲师错误配置方法之后才来网上寻找答案的,没错.拜托那个错误的配置文档之后,重新开启一台虚拟机,铛!!!!!花了4个小时左右,配置成功了. 下面是效果图: 总有一个体会,每次对一件事物感到深刻是对它想吐之后才会有.这次是真的恶心到我

Fastdfs与Nginx的整合

fastdfs在4.06版本以后,就不再支持自带的http服务了,如果需要使用http服务来访问文件,则可以与nginx结合部署,实现http服务. 硬件环境: tracker:192.168.189.146 storage:192.168.189.145 (group1) storage:192.168.189.144 (group2) 软件环境: Tengine_2.0.3 fastdfs-nginx-module_v1.15 假设fastdfs集群已经搭建完成,现开始进行nginx的整合.

FastDFS与Nginx的搭建及遇到的问题

1.1  FastDFS与Nginx的搭建 可以使用一台虚拟机来模拟,只有一个Tracker.一个Storage服务. 配置nginx访问图片. 1.1.1   搭建步骤 第一步:把fastDFS需要用到的压缩包都上传到linux系统. 第二步:安装FastDFS之前,先安装libevent工具包. yum -y install libevent 第三步:安装libfastcommonV1.0.7工具包. 1.下载源码: wget https://github.com/happyfish100/

ubuntu-12.04.2-desktop-amd64 安装整合 nginx + php + mysql + phpmyadmin + tomcat

最近需要做jsp项目,部署在ubuntu 下,周末抽时间配置了nginx + php + mysql + phpmyadmin + tomcat 环境,从windows 的C# 转过来, 多少有些不适应, 估计要走全栈的方向了. 顺便整理了一下入门的配置方法, 完全在控制台下完成. 1.1  Common Start Terminal Ctrl+Alt+T 使用root用户 sudo –sH 查看进程 linux命令ps aux|grep xxx 软连接 ln -s 源地址  目的地址 比如把l

Fastdfs与nginx进行压缩图片比率随记

前阵子,工作搞了一下Fastdfs与nginx进行压缩图片比率存储在server中,今天应用下工作时间记录下.本打算周六,老是由于一些事情给耽搁,眼下正在搞一个XMPP消息通讯协议,眼下还是一头雾水.没有实现什么功能,在此勉励,加油好好搞搞,搞好了记录下一些登录.退出.发送.接收的一些接口给client使用. 在此先把前面自己做的那个功能在此分享下.是一个模仿淘宝的,希望大神们有什么想法能够指教: 參考:http://www.v2ex.com/t/113845 http://blog.sina.

整合Nginx和Tomcat

<--目录--> 1.为什么要整合 Nginx + Tomcat服务 2.安装Nginx 3.安装Jdk 4.安装Tomcat 5.Nginx反向代理负载均衡配置 6.Nginx动静分离配置 7.修改Tomcat访问路径 [为什么要整合 Nginx + Tomcat服务] 1.早期的Resin.Tomcat对httpd服务支持不好 2.Tomcat.Resin,rewrite功能,expires,gzip功能支持不好 3.为了要配动静分离 [安装Nginx] yum -y groupinsta