#

#fastdfs-nginx-module:下载地址

#Nginx1.10.1 下载地址

#ngx-cache-purge:下载地址

#nginx 缓存:详细介绍

#nginx 官方模块详解:http://nginx.org/en/docs/

#nginx 安装(Tracker节点)

#Nginx缓存和反向代理

#下载软件

[root@Tracker ~]# wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
[root@Tracker ~]# wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz

#解压ngx_cache_purge

[root@Tracker ~]# tar -xf ngx_cache_purge-2.3.tar.gz

#编译安装nginx

#安装依赖包(EPEL源)

[root@Tracker ~]# cd nginx-1.10.1/
[root@Tracker nginx-1.10.1]# yum install -y pcre pcre-devel openssl-devel openssl gcc-c++
[root@Tracker nginx-1.10.1]# ./configure --prefix=/usr/local/nginx --add-module=/root/ngx_cache_purge-2.3 --with-http_stub_status_module --with-http_ssl_module
[root@Tracker nginx-1.10.1]# make && make install

#修改配置文件

[root@Tracker ~]# cat /usr/local/nginx/conf/nginx.conf | grep -v "#" | grep -v "^$"
user root;
worker_processes  1;
events {worker_connections  1024;
}
http {include       mime.types;default_type  application/octet-stream;sendfile        on;tcp_nopush     on;keepalive_timeout  65;proxy_cache_path /usr/local/nginx/proxy_cache_path levels=1:2 keys_zone=cache_one:500m inactive=1d max_size=10g;proxy_temp_path /usr/local/nginx/proxy_tmp_path;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_types       text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php;gzip_vary on;upstream fdfs {
server 192.168.174.137:80 max_fails=3 fail_timeout=30s weight=1;
server 192.168.174.138:80 max_fails=3 fail_timeout=30s weight=1;
}server {listen       80;server_name  localhost;location / {root   html;index  index.html index.htm;}
location /group1/M00 {
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_pass http://fdfs;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 600;
proxy_max_temp_file_size 10m;
proxy_busy_buffers_size 256k;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_cache_valid 200 304 12h ;proxy_cache_valid 301 302 1m ;proxy_cache_valid any 1m;
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
}
location ~ /purge(/.*) {allow 127.0.0.1 ;allow 192.168.174.0/24 ;deny all ;proxy_cache_purge cache_one $host$1$is_args$args ;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
}

#测试配置文件是否正确

[root@Tracker ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

#创建缓存目录

[root@Tracker ~]# mkdir -p /usr/local/nginx/proxy_temp_path
[root@Tracker ~]# mkdir -p /usr/local/nginx/proxy_cache_path

#启动服务

[root@Tracker ~]# /usr/local/nginx/sbin/nginx
[root@Tracker ~]# netstat -lntup | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      8787/nginx: master

#nginx 安装(两台Storage节点)

#下载软件

[root@Storage_1 ~]# wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
[root@Storage_1 ~]# wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip
[root@Storage_1 ~]# tar -xf nginx-1.10.1.tar.gz
[root@Storage_1 ~]# unzip master.zip
[root@Storage_1 nginx-1.10.1]# yum install -y pcre pcre-devel openssl-devel openssl gcc-c++
[root@Storage_1 nginx-1.10.1]# ./configure --prefix=/usr/local/nginx --add-module=/root/fastdfs-nginx-module-master/src --with-http_stub_status_module --with-http_ssl_module
[root@Storage_1 nginx-1.10.1]# make && make install
[root@Storage_1 ~]# cp /root/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
[root@Storage_1 ~]# cp /root/fastdfs-master/conf/http.conf /etc/fdfs/
[root@Storage_1 ~]# cp /root/fastdfs-master/conf/mime.types  /etc/fdfs/
[root@Storage_1 ~]# mkdir /data/fdfs/Storage/data/group1
[root@Storage_1 ~]# ln -s /data/fdfs/Storage/data/ /data/fdfs/Storage/data/group1/M00
[root@Storage_1 ~]# vim /etc/fdfs/mod_fastdfs.conf

#修改如下值

tracker_server=192.168.174.136:22122 #第40行
url_have_group_name = true    #第53行
store_path0=/data/fdfs/Storage/   #第60行
log_filename=/usr/local/nginx/logs/mod_fastdfs.log   #第78行

#在server 字段内部增加如下location

[root@Storage_1 ~]# vim /usr/local/nginx/conf/nginx.conf
        location /group1/M00 {root /data/fdfs/Storage/data;ngx_fastdfs_module;}

#测试配置文件

[root@Storage_1 ~]# /usr/local/nginx/sbin/nginx -t
ngx_http_fastdfs_set pid=5336
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

#启动服务

#storage_1

[root@Storage_1 ~]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=5337
#storage_2
[root@Storage_2 ~]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=6263
[root@Storage_1 logs]# curl -I 192.168.174.138
HTTP/1.1 200 OK
Server: nginx/1.10.1
Date: Wed, 19 Apr 2017 22:34:44 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Wed, 19 Apr 2017 22:06:36 GMT
Connection: keep-alive
ETag: "58f7df6c-264"
Accept-Ranges: bytes

#若服务不能正常运行,将/usr/local/nginx/conf/nginx.conf 中第一行 user nobody 修改为 user root

[root@Storage_1 logs]# curl -I 192.168.174.137
HTTP/1.1 200 OK
Server: nginx/1.10.1
Date: Wed, 19 Apr 2017 13:35:50 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Wed, 19 Apr 2017 13:03:25 GMT
Connection: keep-alive
ETag: "58f7601d-264"
Accept-Ranges: bytes

#上传文件

[root@Tracker ~]# echo "hello" > test.txt
[root@Tracker ~]# fdfs_upload_file  /etc/fdfs/client.conf  test.txt
group1/M00/00/00/wKiuiVj3aM-AbzDqAAAABncc3SA048.txt

#Storage_1节点

#Storage_2节点

#stracker节点

#进入缓存目录

[root@Tracker 3b]# pwd
/usr/local/nginx/proxy_cache_path/a/3b  (目录可能不一样)
[root@Tracker 3b]# ls
adc71d260066e8ae813898b1901e33ba

转载于:https://blog.51cto.com/cqwujiang/1917540

FastDFS配置Nginx模块相关推荐

  1. fastDFS 配置 nginx 访问

    fastDFS配置nginx访问 nginx 安装教程 fastDFS 安装教程 安装nginx插件 下载地址 或者fastDFS安装教程里面的百度云有 # 解压nginx的fastdfs压缩包tar ...

  2. FastDFS配置nginx插件访问图片

    搭建nginx 提供http服务 使用官方提供的一个nginx的插件 fastdfs-nginx-module_v1.16.tar.gz 重新编译 要使用nginx插件,需要重新编译 第一步 1.解压 ...

  3. 【nginx】配置ssl模块及使用HTTPS(fastDFS、网页等等)

    一.查看nginx模块 /usr/local/nginx/sbin/nginx -V 啥都没有 二.安装openssl包 yum -y install pcre pcre-devel zlib zli ...

  4. 网络云盘项目——Nginx配置(配置Nginx访问FastCGI、FastDFS)

    一.本文目的 本项目分为6篇博客文章完成: 1.项目总体介绍:https://blog.csdn.net/qq_41453285/article/details/107871393. 2.Redis部 ...

  5. centos安装Fastdfs和Nginx并配置

    FastDfs GitHub源地址 yum install gcc gcc-c++ automake autoconf libtool pcre pcre-devel zlib zlib-devel ...

  6. 通过分析nginx upstream源码来看动态配置upstream模块

    upstream回源处理流程 代码围绕着ngx_http_upstream.c展开,该模块主要为创建mainconf函数: static void *ngx_http_upstream_create_ ...

  7. nginx安装配置ssl模块支持https访问

    文章目录 一.SSL证书 申请免费证书或者购买 1.证书下载 2.配置Nginx 常见错误 错误一: 解决方案: 错误二: 解决方案: 错误三:配置好后https仍然无法访问 情况1:端口443未开放 ...

  8. linux下载安装fastdfs和fastdfs与nginx整合、springboot访问fastdfs

    文章目录 需求分析 分布式文件系统 1 FastDFS安装 FastDFS 和nginx整合 2.整合java访问fastdfs服务 文件上传查询下载测试 整合springboot 需求分析 搭建fa ...

  9. 实现第一个自定义nginx模块

    实现第一个自定义nginx模块 下面的过程详细记录了如何实现第一个自定义的nginx模块,对nginx入门者包括我很有参考价值,特记录如下. 前提 假定以root身份已经在CentOS 6.8 x86 ...

  10. Ubuntu下配置Nginx HTTPS

    HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版.即HTTP下加入S ...

最新文章

  1. 面试了一个 46 岁程序员,思绪万千
  2. k8s Service之LoadBalancer和ExternalName
  3. wxWidgets:wxActiveXEvent类用法
  4. 剑指offer(21)从上往下打印二叉树
  5. 四元素的真面目..........简单粗暴
  6. pq分解法中b’怎么求_14.初中数学:二元一次方程组,加减消元法怎么解?视频有详细解题步骤...
  7. pytorch搭建TextRCNN模型与使用案例
  8. html5下input的placeholder标签兼容ie9
  9. 影响科学圈的“十大名码”!
  10. 规律、逻辑规律与悖论
  11. 重要的Python数据分析库
  12. eclipse tomcat maven热部署
  13. python dateutil_安装python dateutil
  14. idea安装插件方式及个人使用插件
  15. Java-热插拔技术
  16. Java多维数组length
  17. 项目js文件修改后浏览器不能及时更新的解决办法
  18. 百度联盟原负责人周品创办B2C网站
  19. visio电路图怎么连线_还在用visio画电路图?不看后悔!
  20. OCR识别技术之—移动端证件识别

热门文章

  1. cal日历工具的用法
  2. 土人系列AS入门教程--对象篇
  3. 用AtomicStampedReference解决ABA问题
  4. Java(31)_JDBC连接mysql数据库(一)
  5. SpringMVC, Spring和Mybatis整合案例一
  6. bzoj 4551: [Tjoi2016Heoi2016]树
  7. qt超强精美绘图控件 - QCustomPlot一览
  8. 数据库事务复制(读写分离)设计的一点经验
  9. 清华计算机系女生每天看这些公众号
  10. 国外的程序员都是什么样的状态?硅谷程序员:不加班,不穿女装