Nginx 配置 fastdfs-nginx-module 模块

上篇介绍了FastDFS的安装,这里主要是给NG安装fastdfs-nginx-module 模块,来完成FastDFS的上传与下载

安装 Nginx 和 fastdfs-nginx-module

[[email protected] softwares]#wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
fastdfs-nginx-module 直接用附件中的,网上下载的貌似有很多很问题
 
[[email protected] softwares]#tar -zxvf nginx-1.10.1.tar.gz 
[[email protected] softwares]#unzip fastdfs-nginx-module-master.zip
[[email protected] softwares]#cd nginx-1.10.1
[[email protected] nginx-1.10.1]# ./configure --add-module=../fastdfs-nginx-module-master/src/  
[[email protected] nginx-1.10.1]#make
[[email protected] nginx-1.10.1]#make install
[[email protected] nginx-1.10.1]#cd /usr/local/nginx/

我们可以看一下 Nginx 下安装成功的版本及模块
[[email protected] nginx]# sbin/nginx -V
nginx version: nginx/1.10.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
configure arguments: --add-module=../fastdfs-nginx-module-master/src/

配置 fastdfs-nginx-module 和 Nginx

[[email protected] nginx]#cp /data/softwares/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
[[email protected] nginx]#vi /etc/fdfs/mod_fastdfs.conf (修改以下三处)
......
tracker_server=192.168.12.102:22122
.......
url_have_group_name = true
.......
store_path0=/data/fastdfs/storage
....

拷贝相关文件到/etc/fdfs
[[email protected] nginx]#cp /data/softwares/fastdfs-5.05/conf/anti-steal.jpg /etc/fdfs/
[[email protected] nginx]#cp /data/softwares/fastdfs-5.05/conf/http.conf /etc/fdfs/
[[email protected] nginx]#cp /data/softwares/fastdfs-5.05/conf/mime.types /etc/fdfs/
 编辑nginx.conf
 [[email protected] nginx]#vi conf/nginx.conf
 .....
          location /group1/M00 {
             root /data/fastdfs/storage/;
             ngx_fastdfs_module;
         }
 .....
 
[[email protected] nginx]#mkdir /data/fastdfs/storage/data/group1
[[email protected] nginx]#ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/group1/M00 
启动nginx
[[email protected] nginx]#sbin/nginx 
ngx_http_fastdfs_set pid=17697

这样就完成了Nginx  配置 fastdfs-nginx-module 模块

测试下:

开启上传

[[email protected] nginx]#cd /etc/fdfs/
[[email protected] fdfs]#cp client.conf.sample client.conf
......
# the base path to store log files
base_path=/data/fastdfs

# 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.12.102:22122
.......

好了,上传一张图片试试

[[email protected] fdfs]#fdfs_test /etc/fdfs/client.conf upload /tmp/Tulips.jpg
This is FastDFS client test program v5.05

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.

[2017-06-23 09:38:47] DEBUG - base_path=/data/fastdfs, 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.12.102, port=23000

group_name=group1, ip_addr=192.168.12.102, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168.jpg
source ip address: 192.168.12.102
file timestamp=2017-06-23 09:38:47
file size=620888
file crc32=3040764182
example file url: http://192.168.12.102/group1/M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168_big.jpg
source ip address: 192.168.12.102
file timestamp=2017-06-23 09:38:47
file size=620888
file crc32=3040764182
example file url: http://192.168.12.102/group1/M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168_big.jpg

上传后,图片的URL也会出现,我们访问试试

时间: 2024-08-08 07:06:13

Nginx 配置 fastdfs-nginx-module 模块的相关文章

Nginx配置配置文件nginx.conf的设置

引用自:http://www.ha97.com/5194.html #定义Nginx运行的用户和用户组user www www; #nginx进程数,建议设置为等于CPU总核心数.worker_processes 8; #全局错误日志定义类型,[ debug | info | notice | warn | error | crit ]error_log /var/log/nginx/error.log info; #进程文件pid /var/run/nginx.pid; #一个nginx进程打

centos6.5安装配置fastdfs+nginx实现分布式图片服务器

一.准备 yum groupinstall -y "Development Tools"yum install -y wget libevent-devel pcre-devel zlib-devel wget https://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz wget https://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz wget

[Nginx] – 配置优化 – NGINX.CONF [三]

本文主要针对nginx.conf配置文件,下面就把相关配置文件放到下面进行逐一的解释 1.user 语法: user user[group]; 标签: main 定义user和工作group 进程使用的凭证.如果group省略,user则使用名称等于的组. 2.worker_processes 句法: worker_processes number | auto; 默认: worker_processes 1; 标签: main --------------------- 例如, worker_

我整理的一份来自于线上的Nginx配置(Nginx.conf),希望对学习Nginx的有帮助

我整理了一份Nginx的配置文件说明,是真正经历过正式线上考验过.如果有优化的地方,也请朋友们指点一二,整理出一份比较全而实用的配置. 主要包含配置:负载均衡配置,页面重定向,转发,HTTPS和HTTP的配置, 缓存优化,错误页面配置等. #user nobody; #工作进程,于CPU核数一致 worker_processes 2; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/erro

Nginx配置:nginx如何配置跳转fpm

location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param P

CentOS7.1下生产环境Keepalived+Nginx配置

注:下文涉及到配置的,如无特别说明,主备机则一致! 一.环境介绍 1.这是我CentOS的版本,CentOS7.1,主备都为该版本 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.1.1503 (Core) [[email protected] ~]# cat /proc/version Linux version 3.10.0-229.el7.x86_64 ([email protected]) (gc

nginx 配置详解

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用.其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:京东.新浪.网易.腾讯.淘宝等. 一.event模型 传统的基于进程和线程的模型在处理并发连接的时候针对每个连接

ubuntn 配置webpy nginx

webpy环境搭建 在开始webpy搭建之前,有必要熟悉一下什么是fastcgi,因为搭建环境时都是使用这个模式去运行webpy程序的,具体的fastcgi描述可以参考各种百科:fastcgi协议官网(http://www.fastcgi.com/drupal/)上面描述一些基础信息,fastcgi的api.开发,fastcgi的实现程序,支持fastcgi的web服务器等等. 除了fastcgi之外还有一些其他的相关名词:cgi.fastcgi.wsgi.gi是gateway interfac

LNMP(Nginx负载均衡,SSL原理,Nginx配置SSL,生产SSL密钥对)

一.Nginx负载均衡 负载均衡:单从字面上的意思来理解就可以解释N台服务器平均分担负载,不会因为某台服务器负载高宕机而某台服务器闲置的情况.那么负载均衡的前提就是要有多台服务器才能实现,也就是两台以上即可. 在开始部署负载均衡之前,我们先来介绍一个命令,dig命令需要yum安装一下 [[email protected] ~]# yum install bind-utils [[email protected] ~]# dig qq.com            (dig后加域名,他可以返回2个

3. nginx配置的基本语法规则

安装好后的nginx二进制文件中已经指定包含了编译时指定的模块, 每个模块都有自己的配置. 这些配置会遵循相同的nginx配置规则. nginx配置规则: 1) 配置文件由指令和指令块构成, nginx.conf文件中, include就是指令, http就是指令块; 2) 每条指令以;分号结尾, 指令与参数之间以空格符号分隔; 3) 指令块以{}大括号将多条指令组织在一起, 有些指令块有名字, 有些指令块没有名字, 有没有名字由提供该指令块的nginx模块来决定;    4) include语