Trying to install nginx-cache-purge on unbuntu 12.04

I was following your tutorial on adding the cache purge addition when I found your plugin and saw that it was necessary.

I had already installed nginx (I’m new only 1 week using it) and it seems to work great on my digitalocean setup. I have nginx+varnish+apc+ffp+wordpress from following other tutorials prior to finding the rtcamp site tutorials.

I went to brians site and see that he now supports unbuntu 12.04 which is awesome, but when I try to apt-get install nginx-custom, I get the following error, and I don’t know where to begin to fix this.

If I need to remove my install of nginx first, could someone point me out how to do that the right way?


# apt-get install nginx-custom
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
The following NEW packages will be installed:
nginx-common nginx-custom
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/522 kB of archives.
After this operation, 1,176 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database … 41154 files and directories currently installed.)
Unpacking nginx-common (from …/nginx-common_1.4.1-0ppa~precise_all.deb) …
dpkg: error processing /var/cache/apt/archives/nginx-common_1.4.1-0ppa~precise_all.deb (–unpack):
trying to overwrite ‘/etc/logrotate.d/nginx’, which is also in package nginx 1.4.2-1~lucid
No apport report written because MaxReports is reached already
Unpacking nginx-custom (from …/nginx-custom_1.4.1-0ppa~precise_amd64.deb) …
dpkg: error processing /var/cache/apt/archives/nginx-custom_1.4.1-0ppa~precise_amd64.deb (–unpack):
trying to overwrite ‘/usr/sbin/nginx’, which is also in package nginx 1.4.2-1~lucid
No apport report written because MaxReports is reached already
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Processing triggers for man-db …
Processing triggers for ufw …
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

You can try removing previous installed nginx packages.

Use apt-get remove so that only binaries will be removed. Still backup /etc/nginx folder.

After removing old packages, you can try installing fresh ones again.

Also your error shows lucid packages. If you are on Ubuntu 12.04, then have a look at /etc/apt/ entries.

Looks like your system has some old ubuntu repos added to it.

Thanks Rahul
Actually I gave up a few hrs ago and simply erased my droplet and started over using just your settings. I had no problem of course getting it to work then.

This time I am not going to use varnish, but I am going to do my best to follow all of your tutorials and stats letter by letter (well adjusting for my mini-server of course) as I believe in reading that you probably have the most optimized system available.

I only wish I had found your site a week ago. I knew about it, but had no idea about the nginx specialty you guys provide. I’ve now read every single article multiple times and actually wish you had more information believe it or not…lol

w3-total-cache or super-cache, or what?
Now that I do not have varnish and only have apc running, what do you suggest as the most stable best to work with?

Im going to guess w3 as all your articles seem focused on it…

Actually I’m confused.

Your nginx table shows the w3 and fastcgi_cache as separate config files as though if you use one you don’t use the other.

I went through and added fastcgi, so do I not need w3 now?

We use fastcgi_cache for page caching.

w3tc plugin is used for object/mysql cache (with APC backend) only.

Apart from that w3tc is used for CDN.

By the way, since you have a fresh server (or reset if its few minute old), try

curl -sL | sudo bash  
ee system install all  
ee site create wpsingle wpfc

Above 3 lines will be enough to have all packages installed on a fresh server and create single-wordpress site with fastcgi_cache configured with it.

Thank you for the link. Itg is now 9am and I am at the end of a 38hr straight day. I’ve installed/reinstalled so many times now that I quit keeping count and I have read every single article on your entire site here for optimizing the server. It has been a great help.

When I blitz the site now, it is actually horrible compared to my old varnish server and I have spent the last couple of hours working to figure out why. So far it seems that everything is setup and working correctly, but my times are downright lousy.

This rush generated 5,134 successful hits in 1.0 min and we transferred 62.78 MB of data in and out of your app. The average hit rate of 81/second translates to about 7,051,936 hits/day.

The average response time was 164 ms.

You’ve got bigger problems, though: 13.06% of the users during this rush experienced timeouts or errors!


This rush generated 5,961 successful hits in 1.0 min and we transferred 67.18 MB of data in and out of your app. The average hit rate of 95/second translates to about 8,221,668 hits/day.

The average response time was 236 ms.

I had zero timeouts or errors on the prior 7 tests with varnish, this was just an avg test

So, obviously I have some homework to do and some learning ahead of me.

At the least, I can say that I am learning more about setting up a server than I ever thought I would learn and with no gui even, so that’s cool.

EasyEngine is supposed to make things easy as its name suggest. It won’t make performance difference, atleast for now. In future, it will have magic for auto-tuning! :wink:

Now about performance difference, first and obvious question - was caching enabled properly?

Did you check nginx error log? It may give you hint. If nginx ran out of filesystem descriptors, you can try

If its upstream error, that means cache wasn’t running.

Also check gzip compression - (I posted this article 3-4 hours back only)

Also, turn off unnecessary access logs as it adds additional disk I/O for every request.

There is so much we can do! Just have a look at nginx’s error log for site you were testing… :slight_smile:

I noticed that somehow I have nginx 1.4.1 instead of 1.4.2

I believe it happened when I was following the tutorial to add in the extra module for the wordpress plugin to flush the page cache.

Is there a guide on how to upgrade nginx to the latest vs. without loosing the extra modules that I worked so hard to make sure were there during the install?

error log only has 1 error:
2013/07/25 08:24:18 [error] 2076#0: *882 access forbidden by rule, client: x.x.x.x, server:, request: “GET /nginx_status HTTP/1.1”, host: “

I will go through and check everything else you mentioned before I crash n burn for the day/night

this was a private reply with post_id 43278

You need to add your own IP or remove deny all from location /nginx_status {…} block to get away with forbidden error.

Thanks, yes I have no problem accessing the status page. I only made the change so that you could see them as well if needed to help troubleshoot my setup. I have also added the fpm status page so I can watch that, though I’m not really sure when looking at the pages as to what is good and bad numbers. I just know that when I blitz my server right now to test it, I get a lot of timeouts where under the old way with varnish I didn’t. That leads me to believe that maybe I have something configured wrong even though it seems that everything is working.

Ok, I think I get it. I basically have to download all the extra modules that I want to use to my own server and actually add the paths to them each and every time I rebuild. Makes sense I think. Thanks for the info

Yep. :slight_smile:

Sometime extra modules have dependencies. You can go trail-and-error. It may take time but this is the way to build it!

You may find this useful -

I gave it a try almost 2 years back and it worked then. :slight_smile:

Yes it does work, I tried it a couple of days ago.
Basically I am trying to learn how to do this on my own using best practices.

I have never had to add modules with dependencies before and trying to find docs on how best to do it with multiple dependencies has been a challenge.

Most sites give you a good example on how to load their own dependency for nginx, but I have yet to find a guide showing how to load multiple modules with multiple dependencies when re-building nginx. I suppose that is where I’m at now so that I don’t have to rely upon someone elses script, I can simply rebuild nginx everytime I find a new module with dependencies that I want to use. Trying to become self-sufficient in that :slight_smile:

I always resolve dependencies by trial-n-error.

Just start compilation. Process will break if a dependency is missing. Google for error. Install dependency. Start again!

I keep taking notes of dependencies on the way so if I need to repeat compilation process later on, I can save some time.

Well I’m 3 days into this now and have literally tried everything I can think of. I’ve destroyed and recreated my applet dozens of times and never can get it right, so need to ask for some help.

I followed your awesome guide for fastcgi

Now I just want to add the google pagespeed to that package somehow.

Would you please consider writing up a quick how-to guide on how we should go about upgrading nginx (his is old 1.4.1 vs.) and also how to add pagespeed as well to it?

*I don’t think that there is an article anywhere online on how to compile nginx with lots of different 3rd party modules and built in extensions where you can also auto update via apt-get. If there is, I would love to have the link as I have searched everywhere and tried everything I can think of.

We are already working on nginx build with google-pagespeed. We will post about it in future.