Mar 142011

I’m not going have much words to say, here we go..

first download nginx source rpm from this excellent contributor/packager and install the source

$ wget
$ rpm -Uvh  nginx-0.9.5-1.el5.src.rpm

Change to /path/rpm/SOURCE and download ngx_cache_purge

$ cd `rpm --eval '%{_sourcedir}'`
$ wget

Now we need to modified nginx.spec a bit, so it will include ngx_cache_purge module when compiled

$ cd `rpm --eval '%{_specdir}' `
$ vi nginx.spec

Add ngx_cache_source-1.2.tar.gz module to source list as Source20

Source11:       nginx_mod_h264_streaming-2.2.7.tar.gz
Source20:       ngx_cache_purge-1.2.tar.gz

In %prep section add this line %setup -T -D -a 20

%setup -T -D -a 11
%setup -T -D -a 20
%setup -T -D -a 21

In %build section add this line –add-module=%{_builddir}/nginx-%{version}/ngx_cache_purge-1.2 \

    --add-module=%{_builddir}/nginx-%{version}/nginx_upload_module-2.2.0 \
    --add-module=%{_builddir}/nginx-%{version}/ngx_cache_purge-1.2 \

Add these line under make command

mv ngx_cache_purge-1.2/CHANGES ngx_cache_purge-1.2/CHANGES.ngx_cache_purge
mv ngx_cache_purge-1.2/README ngx_cache_purge-1.2/README.ngx_cache_purge

Under %files section add this line %doc ngx_cache_purge-1.2/CHANGES.ngx_cache_purge ngx_cache_purge-1.2/README.ngx_cache_purge

%doc nginx-upload-progress-module/CHANGES.nginx_uploadprogress_module nginx-upload-progress-module/README.nginx_uploadprogress_module
%doc ngx_cache_purge-1.2/CHANGES.ngx_cache_purge ngx_cache_purge-1.2/README.ngx_cache_purge


save nginx.spec, build all, install rpm binary

$ rpmbuild -ba nginx.spec
$ sudo rpm -Uvh /path/to/RPMS/nginx-0.9.5-1.....rpm

Edit nginx.conf add this location

location ~ /purge(/.*)
   allow  ;
   allow  ;
   deny             all;
   proxy_cache_purge    staticfilecache  "$scheme://$host$1";

staticfilecache is keys_zone change this to what ever keys_zone you’ve defined in proxy_cache_path
“$scheme://$host$1” is proxy_cache_key

Reload/restart nginx

Here’s example purging from command line

$ lynx -dump -source
<head><title>Successful purge</title></head>
<body bgcolor="white">
<center><h1>Successful purge</h1>
<br>Key :
<br>Path: /var/lib/nginx/7/cc/772cdb140a788c0cf099c53a21160cc7


 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>