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文件中执行

本文介绍如何通过四个步骤将Memcached与Nginx进行集成:下载memc-nginx-module模块,编译安装该模块,配置nginx.conf启用404错误页缓存功能,并重启Nginx服务。最终实现通过Memcached缓存静态资源,提高网站响应速度。
6627

被折叠的 条评论
为什么被折叠?



