參考資料:
檢視nginx編譯參數:
<code>[root@test31 php]</code><code># /usr/local/nginx/sbin/nginx -V</code>
<code>nginx version: nginx</code><code>/1</code><code>.6.3</code>
<code>built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) </code>
<code>TLS SNI support enabled</code>
<code>configure arguments: --prefix=</code><code>/usr/local/nginx</code> <code>--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=</code><code>/usr/local/src/openssl-1</code><code>.0.1c --with-zlib=</code><code>/usr/local/src/zlib-1</code><code>.2.8 --with-pcre=</code><code>/usr/local/src/pcre-8</code><code>.36</code>
下載下傳ngx_cache_purge,然後解壓
<code>[root@test31 nginx-1.6.3]</code><code># wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz</code>
<code>[root@test31 nginx-1.6.3]</code><code>#tar -zxvf ngx_cache_purge-2.3.tar.gz</code>
傳回nginx之前編譯的目錄,使用--add-module=/usr/local/src/ngx_cache_purge-2.3,将ngx_cache_purge添加編譯
<code>[root@test31 src]</code><code># cd nginx-1.6.3</code>
<code>[root@test31 nginx-1.6.3]</code><code># pwd</code>
<code>/usr/local/src/nginx-1</code><code>.6.3</code>
<code>[root@test31 nginx-1.6.3]</code><code>#./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</code>
<code>[root@test31 nginx-1.6.3]</code><code>#make</code>
<code>[root@test31 nginx-1.6.3]</code><code>#make install</code>
無報錯,重新編譯結束,檢視nginx編譯參數
<code>[root@test31 nginx-1.6.3]</code><code># /usr/local/nginx/sbin/nginx -V</code>
<code>configure arguments: --prefix=</code><code>/usr/local/nginx</code> <code>--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=</code><code>/usr/local/src/openssl-1</code><code>.0.1c --with-zlib=</code><code>/usr/local/src/zlib-1</code><code>.2.8 --with-pcre=</code><code>/usr/local/src/pcre-8</code><code>.36 --add-module=</code><code>/usr/local/src/ngx_cache_purge-2</code><code>.3</code>
二.清除nginx反向代理緩存
安裝ngx_cache_purge的目的是為了清除nginx反向代理伺服器上的檔案緩存,不過今天線上伺服器因為沒有ngx_cache_purge擴充
<code>[wo@yy235 ~]$ </code><code>cd</code> <code>/usr/local/nginx/conf/vhost</code><code>.d/</code>
<code>[wo@yy235 vhost.d]$ </code><code>more</code> <code>www.yu23.com.conf</code>
<code>proxy_cache_path </code><code>/var/cache/web/www</code><code>.yu23.com levels=1:1:2 keys_zone=search:4096m</code>
<code> </code><code>inactive=30m max_size=16g;</code>
找到緩存檔案目錄
<code>/var/cache/web/www</code><code>.yu23.com</code>
直接删除目錄下所有檔案,成功清楚緩存。這個辦法很黃很暴力,不适合大流量網站使用。
建議還是用官網的解決辦法進行。
本文轉自 yawei555 51CTO部落格,原文連結:http://blog.51cto.com/huwei555/1691931,如需轉載請自行聯系原作者