X

How to compile Nginx with Nginx Cache Purge Module on Ubuntu 12.04 (Precise Pangolin)

Nginx Cache Purge module is one of the Nginx's very useful module , which helps in clearing/purging the fastcgi cache in case fastcgi caching is enabled. Let us check out on how can we recompile Nginx with cache purge module on Ubuntu platform

Now days Nginx has proven itself as a primary choice for running scalable web architecture , specially for heavy traffic websites. It has also established itself as a feature rich webserver with lot of open source enthusiast contributing towards the module development.

Nginx Cache Purge module is one of the Nginx’s very useful module , which helps in clearing/purging the fastcgi cache in case fastcgi caching is enabled. Let us check out on how can we recompile Nginx with cache purge module on Ubuntu platform

Server:-

Distributor ID: Ubuntu
Description   : Ubuntu 12.04.4 LTS
Release       : 12.04
Codename      : precise

Nginx Info. :-

Version       : 1.6.2

Module        : ngx_cache_purge-master

Module version: 2.2

 

Configuration steps:-

Step 1:- Make directory with any name in any location which will be utilized for downloading the nginx source package

mkdir custom1.6.2

cd custom6.2

Step 2 :- Now install prerequisite packages  used to compile Nginx source and download the latest Nginx source from the respository

sudo apt-get install dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev unzip  python-software-properties software-properties-common

sudo add-apt-repository ppa:nginx/stable

sudo apt-get update

sudo apt-get source nginx

Step 3:- Download the latest stable version of Nginx cache purge module source (Currently latest stable version is v2.2 ) :-

wget https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip

unzip master.zip

cp  -pr ngx_cache_purge-master  nginx-1.6.2/debian/modules/

Step 4 :- Add the nginx cache module in nginx rule:-

Now go to the rules file and add (–add-module=$(MODULESDIR)/ngx_cache_purge-master\) in full configure flags

vi nginx-1.6.2/debian/rules



full_configure_flags := \
$(common_configure_flags) \
--with-http_addition_module \
--with-http_dav_module \
--with-http_geoip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_spdy_module \
--with-http_sub_module \
--with-http_xslt_module \
--with-mail \
--with-mail_ssl_module \
--add-module=$(MODULESDIR)/nginx-auth-pam \
--add-module=$(MODULESDIR)/ngx_cache_purge-master\
--add-module=$(MODULESDIR)/nginx-dav-ext-module \
--add-module=$(MODULESDIR)/nginx-echo \
--add-module=$(MODULESDIR)/nginx-upload-progress \
--add-module=$(MODULESDIR)/nginx-upstream-fair \
--add-module=$(MODULESDIR)/ngx_http_substitutions_filter_module

Step 5 :- Compile the nginx source to produce a deb file using dpkg-buildpackage command

cd nginx-1.6.2

sudo apt-get install dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev unzip  dh-systemd libgd2-noxpm-dev libluajit-5.1-dev liblua5.1-0-dev libmhash-dev libpam0g-dev libperl-dev

dpkg-buildpackage -uc -b -j2

Step 6 :- Check deb file:-

cd ../

ls


Result of ls

nginx_1.6.2-5+precise0_all.deb
nginx_1.6.2-5+precise0_amd64.changes
nginx_1.6.2-5+precise0.debian.tar.gz
nginx_1.6.2-5+precise0.dsc
nginx_1.6.2.orig.tar.gz
nginx-common_1.6.2-5+precise0_all.deb
nginx-doc_1.6.2-5+precise0_all.deb
nginx-extras_1.6.2-5+precise0_amd64.deb
nginx-extras-dbg_1.6.2-5+precise0_amd64.deb
nginx-full_1.6.2-5+precise0_amd64.deb
nginx-full-dbg_1.6.2-5+precise0_amd64.deb
nginx-light_1.6.2-5+precise0_amd64.deb

Step 7 :- Install nginx and check the module:-

dpkg -i nginx-common_1.6.2-5+precise0_all.deb nginx-full_1.6.2-5+precise0_amd64.deb

if you are getting some error in installation try the following:-

apt-get install -f

Check for the presence of Nginx cache purge module in current installation using Verbose switch :-

nginx -V

Result:-

nginx version: nginx/1.6.2
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security 
-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf 
--http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock 
--pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi 
--http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi
 --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module
 --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module
 --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module
 --with-mail --with-mail_ssl_module --add-module=/root/custom-1.6.2/nginx-1.6.2/debian/modules/nginx-auth-pam 
--add-module=/root/custom-1.6.2/nginx-1.6.2/debian/modules/ngx_cache_purge-2.2 
--add-module=/root/custom-1.6.2/nginx-1.6.2/debian/modules/nginx-dav-ext-module 
--add-module=/root/custom-1.6.2/nginx-1.6.2/debian/modules/nginx-echo 
--add-module=/root/custom-1.6.2/nginx-1.6.2/debian/modules/nginx-upload-progress 
--add-module=/root/custom-1.6.2/nginx-1.6.2/debian/modules/nginx-upstream-fair

 

 

  • Tags: linux, nginx, nginx cache purge, nginx cache purge module, nginx on ubuntu,