nginx重新编译添加ngx_cache_purge扩展

简介:

参考资料:

nginx官网ngx_cache_purge扩展参考:http://wiki.nginx.org/CachePurgeChs

张宴的技术博文:http://zyan.cc/nginx_cache/

查看nginx编译参数:

1
2
3
4
5
[root@test31 php] # /usr/local/nginx/sbin/nginx -V
nginx version: nginx /1 .6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) 
TLS SNI support enabled
configure arguments: --prefix= /usr/local/nginx  --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl= /usr/local/src/openssl-1 .0.1c --with-zlib= /usr/local/src/zlib-1 .2.8 --with-pcre= /usr/local/src/pcre-8 .36

下载ngx_cache_purge,然后解压

1
2
[root@test31 nginx-1.6.3] # wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
[root@test31 nginx-1.6.3] #tar -zxvf ngx_cache_purge-2.3.tar.gz

返回nginx之前编译的目录,使用--add-module=/usr/local/src/ngx_cache_purge-2.3,将ngx_cache_purge添加编译

1
2
3
4
5
6
[root@test31 src] # cd nginx-1.6.3
[root@test31 nginx-1.6.3] # pwd
/usr/local/src/nginx-1 .6.3
[root@test31 nginx-1.6.3] #./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1c --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36 --add-module=/usr/local/src/ngx_cache_purge-2.3
[root@test31 nginx-1.6.3] #make
[root@test31 nginx-1.6.3] #make install

无报错,重新编译结束,查看nginx编译参数

1
2
3
4
5
[root@test31 nginx-1.6.3] # /usr/local/nginx/sbin/nginx -V
nginx version: nginx /1 .6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) 
TLS SNI support enabled
configure arguments: --prefix= /usr/local/nginx  --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl= /usr/local/src/openssl-1 .0.1c --with-zlib= /usr/local/src/zlib-1 .2.8 --with-pcre= /usr/local/src/pcre-8 .36 --add-module= /usr/local/src/ngx_cache_purge-2 .3

二.清除nginx反向代理缓存

安装ngx_cache_purge的目的是为了清除nginx反向代理服务器上的文件缓存,不过今天线上服务器因为没有ngx_cache_purge扩展

1
2
3
4
[wo@yy235 ~]$  cd  /usr/local/nginx/conf/vhost .d/
[wo@yy235 vhost.d]$  more  www.yu23.com.conf
proxy_cache_path  /var/cache/web/www .yu23.com  levels=1:1:2 keys_zone=search:4096m
                                         inactive=30m  max_size=16g;

找到缓存文件目录

1
/var/cache/web/www .yu23.com

直接删除目录下所有文件,成功清楚缓存。这个办法很黄很暴力,不适合大流量网站使用。

建议还是用官网的解决办法进行。



本文转自 yawei555 51CTO博客,原文链接:http://blog.51cto.com/huwei555/1691931,如需转载请自行联系原作者

相关文章
|
1月前
|
安全 应用服务中间件 nginx
|
5月前
|
开发框架 应用服务中间件 API
扩展Nginx的无限可能:掌握常见扩展模块和第三方插件的使用方法
扩展Nginx的无限可能:掌握常见扩展模块和第三方插件的使用方法
316 0
|
8月前
|
缓存 负载均衡 NoSQL
山东布谷科技直播软件源码Nginx服务器横向扩展:搭建更稳定的平台服务
Nginx服务器横向扩展提高了[直播软件源码](https://developer.aliyun.com/article/1302799?spm=a2c6h.13148508.setting.15.65934f0e6yi0Cp)性能,使直播软件源码平台性容错性、负载能力、处理高并发能力等能力有了极大地提升,确保了平台向着更高心梗、更稳定的方向发展,并且这样,使用户的体验大大增加,增加用户黏性,增多了用户的数量。
山东布谷科技直播软件源码Nginx服务器横向扩展:搭建更稳定的平台服务
|
应用服务中间件 Linux 网络安全
|
缓存 Java 应用服务中间件
用 Java 扩展 Nginx(nginx-clojure 入门实战)
让 Java 代码直接在 Nginx 上运行?这么有趣的功能,随本文一起来实战体验吧,图文并茂,一定能成功的那种实战
1278 1
用 Java 扩展 Nginx(nginx-clojure 入门实战)
|
应用服务中间件 nginx
nginx配置文件语法高亮的Sublime Text扩展
nginx配置文件语法高亮的Sublime Text扩展
392 0
nginx配置文件语法高亮的Sublime Text扩展
|
tengine 负载均衡 应用服务中间件
|
应用服务中间件 PHP nginx