Mastodon

Nginx, WordPress Network, and Fastcgi Cache: The Ultimate Guide.

Update: new sections in the nginx config for handling the wordpress admin section!

Update: new upstart script.
Update Feb 9, 2016 No longer need ngx_cache_purge compiled in, Ubuntu 14.04+ specific.

In honor of Antirez’ fantastic post here: On the web server scalability and speed are almost the same thing, I’m sharing my Nginx configuration for WordPress Network (previously WordPress-Mu).

I’m assuming you are running ubuntu and you know the basics of system administration. I’m also assuming you’re using some sort of fastcgi backend. I suggest this excellent howto from interfacelab as an excellent starting point.

First, go get the nginx mainline PPA. Might need to install common-software-properties first.

Next,in your nginx.conf, add this line in the http section:

This creates a cache of 64MB. It’s stored in memory, so be sure you’ve got overhead. If you’re running a blog, unless you’ve got HUGE files, it’s unlikely you’ll need this much cache, and you can probably safely pare this down further to save memory.

And the final piece, the server configuration for nginx. Note the usage of the variable $nocache, and also the purge location.

Be sure to install the nginx_proxy_cache_purge plugin, and activate it network wide. And that’s it!

Just for kicks, try:

Post your results in the comments!

If you happen to be using a recent ubuntu, try this out for your upstart script

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Mastodon