FastDFS配置Nginx模块

#

#fastdfs-nginx-module:下载地址

#Nginx1.10.1 下载地址

#ngx-cache-purge:下载地址

#nginx 缓存:详细介绍

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

#nginx 安装(Tracker节点)

#Nginx缓存和反向代理

#下载软件

[[email protected] ~]# wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

[[email protected] ~]# wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz

#解压ngx_cache_purge

[[email protected] ~]# tar -xf ngx_cache_purge-2.3.tar.gz

#编译安装nginx

#安装依赖包(EPEL源)

[[email protected] ~]# cd nginx-1.10.1/

[[email protected] nginx-1.10.1]# yum install -y pcre pcre-devel openssl-devel openssl gcc-c++

[[email protected] 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

[[email protected] nginx-1.10.1]# make && make install

#修改配置文件

[[email protected] ~]# 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;

}

}

}

#测试配置文件是否正确

[[email protected] ~]# /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

#创建缓存目录

[[email protected] ~]# mkdir -p /usr/local/nginx/proxy_temp_path

[[email protected] ~]# mkdir -p /usr/local/nginx/proxy_cache_path

#启动服务

[[email protected] ~]# /usr/local/nginx/sbin/nginx

[[email protected] ~]# netstat -lntup | grep 80

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      8787/nginx: master

#nginx 安装(两台Storage节点)

#下载软件

[[email protected]_1 ~]# wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

[[email protected]_1 ~]# wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip

[[email protected]_1 ~]# tar -xf nginx-1.10.1.tar.gz

[[email protected]_1 ~]# unzip master.zip

[[email protected]_1 nginx-1.10.1]# yum install -y pcre pcre-devel openssl-devel openssl gcc-c++

[[email protected]_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

[[email protected]_1 nginx-1.10.1]# make && make install

[[email protected]_1 ~]# cp /root/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/

[[email protected]_1 ~]# cp /root/fastdfs-master/conf/http.conf /etc/fdfs/

[[email protected]_1 ~]# cp /root/fastdfs-master/conf/mime.types  /etc/fdfs/

[[email protected]_1 ~]# mkdir /data/fdfs/Storage/data/group1

[[email protected]_1 ~]# ln -s /data/fdfs/Storage/data/ /data/fdfs/Storage/data/group1/M00

[[email protected]_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行

[[email protected]_1 ~]# vim /usr/local/nginx/conf/nginx.conf

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

location /group1/M00 {

root /data/fdfs/Storage/data;

ngx_fastdfs_module;

}

#测试配置文件

[[email protected]_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

[[email protected]_1 ~]# /usr/local/nginx/sbin/nginx

ngx_http_fastdfs_set pid=5337

#storage_2

[[email protected]_2 ~]# /usr/local/nginx/sbin/nginx

ngx_http_fastdfs_set pid=6263

[[email protected]_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

[[email protected]_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

#上传文件

[[email protected] ~]# echo "hello" > test.txt

[[email protected] ~]# fdfs_upload_file  /etc/fdfs/client.conf  test.txt

group1/M00/00/00/wKiuiVj3aM-AbzDqAAAABncc3SA048.txt

#Storage_1节点

#Storage_2节点

#stracker节点

#进入缓存目录

[[email protected] 3b]# pwd

/usr/local/nginx/proxy_cache_path/a/3b  (目录可能不一样)

[[email protected] 3b]# ls

adc71d260066e8ae813898b1901e33ba

时间: 2024-12-25 20:41:30

FastDFS配置Nginx模块的相关文章

FastDFS 配置 Nginx 模块-Linux

1.搭建虚拟机 a.复制虚拟机文件 首先复制我们之前安装好的fastdfs虚拟机,因为我们现在要设置它的IP为21,改名为CentOS-fastdfs - 21. b.设置网络 生成新的MAC地址 设置网络地址为192.168.50.21  # vi /etc/sysconfig/network-scripts/ifcfg-ens33 修改主机名 #vi /etc/sysconfig/network # vi /etc/hosts 重启网络并测试 2.安装配置Nginx模块  a.fastdfs

FastDFS的php和nginx模块配置

一.FastDFS和php整合 1.安装php # 安装依赖包 yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel cu

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

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] so

搭建FastDFS分布式存储环境(使用Nginx模块)

上次搭建FastDFS使用的版本是v4.05,见http://www.linuxidc.com/Linux/2014-10/107592.htm这个版本已经比较旧了 最新的版本是v5.04,由于作者重构了代码,所以安装过程还是有一些不一致.最新版本下载地址:http://sourceforge.net/projects/fastdfs/files/安装可以参考压缩包内的INSTALL文件. 实验还是搭建一个FastDFS环境,并增加Nginx模块所用软件:FastDFS_v5.04.tar.gz

php5.5安装及phpmyadmin&nginx配置php模块

安装php5.5: 下载源地址:rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm rpm包安装:yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-

Linux下安装php环境并且配置Nginx支持php-fpm模块[www]

Linux下安装php环境并且配置Nginx支持php-fpm模块 http://www.cnblogs.com/freeweb/p/5425554.html 5分钟搭建 nginx +php --------------(LNMP)新手专用 http://blog.csdn.net/dyllove98/article/details/41120789 配置Nginx来支持php http://www.cnblogs.com/jecyhw/p/5504855.html nginx+php的配置与

php5.5安装及phpmyadmin&nginx配置php模块

安装php5.5: 下载源地址:rpm -Uvh rpm包安装:yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64 安装后如需要调用mysql模块需要安装mysql依赖: yum ins

TFS的nginx模块配置

在部署完基本的tfs环境之后,就可以通过tfstool工具开始上传文件,上传完的文件可以通过ds_client工具来读取,也可以通过web方式来展示,本文介绍nginx的tfs模块配置来实现http形式展现tfs文件系统上传后的文件.当然如果你高兴的话,也可以用tengine来实现. 环境介绍: tfs nameserver服务器  192.168.1.225/24 tfs dataserver服务器  192.168.1.227/24 tfs-nginx服务器       192.168.1.