1.下载memc-nginx-module
https://github.com/openresty/memc-nginx-module/tags
2.编译memc-nginx-module
https://github.com/openresty/memc-nginx-module/tags
2.编译memc-nginx-module
./configure --prefix=/opt/nginx \ --add-module=/path/to/memc-nginx-module
make && make install
3. 配置nginx conf文件
在http部分打开404
fastcgi_intercept_errors on;
location /foo{
add_header Content-Type 'text/html; charset=utf-8';
set $memc_cmd 'get';
set $memc_key $query_string;
memc_pass 127.0.0.1:11211;
}
error_page 404 /memcached.php?skip=$query_string;
4.重启nginx
在浏览器中输入http://192.168.1.122/foo?key
将会从memcache中获取页面 如果没命中跳转到php文件中执行