nginx, apache & cdn's


I am currently setting up a codeigniter & wordpress application using apache. I am now finding out more about nginx and the power it has.

I am planning to use a CDN (Amazon or Rackspace) for handling my images, videos, css, javascript. In this case, would I still see a performance boost from using nginx (reverse proxying to apache)?

The other option is using nginx as the sole webserver and remove apache completely. I do have some complex .htaccess rules, so not sure if it will all translate, but if I pursue this route, would i still see a performance improvement?

so the options are:

a) nginx + apache + cdn

b) apache + cdn

c) nginx + cdn


13 Replies

I see little benefit to mixing and matching multiple webservers simultaneously. nginx or apache, pick one and stick with it.

If your Linode is only going to serve dynamic content, then there's not much point in a reverse proxy. Perhaps you might see some performance difference between Apache and nginx but since each request still needs a PHP interpreter instance to run on, it seems like this would be minimal.

Thanks for the advice. I will look into using Nginx as my sole web server and see if i can massage the current .htaccess files into it.

One interesting thing I found in my research is that if I can cache the whole page, then I can have that displayed before needing to involve the php interpreter. I can do this because I have an ecommerce site and most of my pages are not changing much and are not personalized.

The 3 ways of doing that are:

a) Use varnish in front of nginx / apache to serve the entire cached pages

b) Use nginx's cache module to cache the pages.

c) Use nginx as the web server along with memcached integration. This way, my codeigniter application would add the page to memcached and then nginx would deliver that page if it exists in memcached. further details are here: … e-way-down">

Option b and c seem the most interesting, and leaning toward option c I think.

Just keep in mind that Varnish is designed/intended to sit on its own dedicated box, using a very large swap file/partition as disk cache.

thanks for the advice on varnish. if i go the nginx + memcached route, where would you recommend i put memcached?

i currently am configuring 3 linodes:

  • a web server (512 MB)

  • master database server (1GB)

  • slave database server (512 GB).

should i place memcached on the web server and increase the memory or place it on the slave database server as it will probably have the lowest usage of the 3 linodes.


From experience, I'd recommending using nginx on its own with PHP-FPM, and not nginx->apache. Converting the rewrites isn't too difficult, and there are decent convertors to help you along (although they are not 100% accurate but will help).

I also recommend using nginx's cache to cache your Wordpress pages. There is a Wordpress plugin that sends appropriate headers to nginx. I got something crazy like 9000 requests/second from a small Linode using this. I wouldn't bother using memcached for this.

thanks, i was able to get nginx configured with my previous .htaccess rules and don't need to use apache anymore. i actually like nginx's syntax and found it just as easy if not easier than apache.

i will look into the nginx cache further as well. who knew that there was so much performance improvement over lamp which i've been using over the past 5 years.

If you are using PHP-FPM which you likely will, pay attention to the various tuning settings there including emergency restarting.

ok, thanks, i will look into that. can monit be configured for php-fpm as well? i have that configured to watch nginx.

I don't know about monit, but I do use munin with it.

nevermind, i found the pid in the php-fpm.conf file and i can use that to add it in monit. i will add the settings in fpm as well

I should look into monit one day

yeah, it's pretty nice. here's an example from a linode user to get started with an example configuration.

you can install it through the package manager to get started.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct