wdcsx 发表于 2015-11-18 08:46:22

nginx支持redis,实现替换nginx+memcache方式

  http://hi.baidu.com/dekar/blog/item/19bd061595aa2819c93d6d87.html


  需要下载第三方模块ngx_http_redis-0.3.2.tar.gz,并需要重新编译nginx。

注意要注释掉ngx_http_redis_module.c文件的145行

/*static ngx_str_tngx_http_redis_db= ngx_string("redis_db");*/

否则会报错,意思是这个定义的redis_db在程序里没有使用,算是个警告报错,注释掉安装即可



./configure --user=nginx --group=nginx--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/software/module/ngx_http_redis-0.3.2





配置

location / {
set $redis_key $uri;
redis_pass   name:6379;
default_type   text/html;
error_page   404 = /fallback;
}


$redis_db
  The number of redis database (required for < 0.3.2).
  For ngx_http_redis >= 0.3.2 is not obligatory, default value is &quot;0&quot; if not defined.
  这个$redis_db可以不配,默认是0database。

更多官方的资料请参考:http://wiki.nginx.org/HttpRedis2Module
页: [1]
查看完整版本: nginx支持redis,实现替换nginx+memcache方式