• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

Install The ngx_cache_purge Module In Nginx

ngx_cache_purge module

Ngx_cache_purge is a module which will allow the fastcgi_cache, proxy, SCGI and uWSGI caches to have content purged from them. The caches allow precompiled code to be served as opposed to running a new version each time. This can greatly reduce the amount of processing power per page request.  This specific module allows that cached content to be purged when needed.  To compile this module from source if you have done a source build of Nginx like this Nginx Compile From Source On CentOS. Adding the module is pretty straightforward. You can read more about the module here

First get the ngx_cache_purge package

wget -O /usr/src/ngx_cache_purge-2.3.tar.gz  http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz

Uncompress the package

tar xfvz ngx_cache_purge-2.3.tar.gz

cd to your Nginx build directory

cd /usr/src/nginx-1.11.13

Get the prior build configuration options

# nginx -V
 nginx version: nginx/1.11.13
 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
 built with OpenSSL 1.0.1e-fips 11 Feb 2013
 TLS SNI support enabled
 configure arguments: --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module --with-http_realip_module

Copy all of the configure arguments and append –add-module=/path/to/ngx_cache_purge

./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module --with-http_realip_module --add-module=/usr/src/ngx_cache_purge-2.3

Once configure has finished, You can go ahead perform  a make and install it

make

make install

Then restart nginx

/etc/init.d/nginx restart

Run the following to ensure the module is now loaded:

nginx -V 2>&1 | grep ngx_cache_purge -o

It should return ngx_cache_purge if it is.

That is all you need to do to add the module to a Nginx build.

May 28, 2017LinuxAdmin.io
5 1 vote
Article Rating
Nginx Load BalancingNginx Caching for Wordpress using fastcgi_cache
You Might Also Like
 
KVM Virsh Console Access on CentOS 7
 
MySQL Replication Master Slave Setup
Subscribe
Notify of
guest
guest
8 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Chip
Chip
5 years ago

(dummy here)
I just get: -bash: ./configure: No such file or directory
whenever I try that long list of commands. Any advise?

-1
Reply
LinuxAdmin.io
Author
LinuxAdmin.io
5 years ago
Reply to  Chip

Did you cd to the source directory after uncompressing it?

0
Reply
Mike
Mike
4 years ago
Reply to  LinuxAdmin.io

Me too, I followed the exact steps you told, but I get ./configure: No such file or directory. I did cd to nginx dir. Why don’t yo make a video and upload in youtube?

0
Reply
LinuxAdmin.io
Author
LinuxAdmin.io
4 years ago
Reply to  Mike

Hello Mike,
If there is no configure, then you are not in the right directory. Could you please provide a listing inside of the nginx directory?

0
Reply
Jef
Jef
4 years ago

Is it possible to use the module in an already installed nginx without having to compile the current one?

0
Reply
LinuxAdmin.io
Author
LinuxAdmin.io
4 years ago
Reply to  Jef

Hello Jef,
If you already have the module installed (check nginx -V output) you certainly can use that.

0
Reply
Sergey
Sergey
4 years ago

Hello! I did everything according to the instructions. I execute a command: nginx -V 2> & 1 | grep ngx_cache_purge -o but I get nothing in return. Configure the arguments: –sbin-path = / usr / sbin –conf-path = / etc / nginx / nginx.conf –error-log-path = / var / log / nginx / error.log -pid-path = / var / run / nginx.pid – lock-path = / var / lock / nginx.lock –http-log-path = / var / log / nginx / access.log –http-client-body-temp – path = / var / lib / nginx / body –http-proxy-temp-path = / var / lib /… Read more »

0
Reply
LinuxAdmin.io
Author
LinuxAdmin.io
4 years ago
Reply to  Sergey

Could you paste the output of just nginx -V

0
Reply
5 years ago 8 Comments Linux Tutorials, Nginx, Web Hosting centos, Linux Performance Tuning5,677
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
62,994 views
Zend Opcache
Setup and Optimize Zend OpCache
46,714 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,910 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz