Lighting a fire under Wordpress
A museum piece from 2011, restored in 2026 and left as written apart from comments marked 2026 and corrections to the configuration files. The software versions are long out of support, so read it as history rather than a how-to. Links that died are unlinked and explained in the notes at the end, and the configuration files, once embedded gists, now sit in the page.
Since I moved my personal web site from Roller to Wordpress a couple of years ago, my web site had been a dog. After reading an article about a PHP-based web site configured to support 9 millions hits per day, and knowing through experience that my site should be significantly faster, I decided it was time to light a fire under Wordpress.
(Note that I've included gists at the bottom of the article with the important configuration files.)
I was using a Slicehost1 slice with a typical Apache/mod_php configuration but there wasn't enough memory so it would start swapping with a little use which caused frequent outages. But rather than upgrade to the next sized Slice, I found that I could double my RAM for the same money simply by moving to Linode. So that was the first change I made. (FWIW, I'm not suggesting this as a performance enhancement but it's definitely a better value.)
Next was a series of changes, some of which were noted in the Tumbledry article, some not. The Tumbledry article was thin on details so I did the research myself and came up with a number of articles with the best being this article on setting up nginx, PHP-FPM, APC (2026: replaced by OPcache, which has shipped inside PHP since 5.5), memcached and the W3 Total Cache Wordpress plugin. The cryptkcoding article shows how to setup an Ubuntu Linux system for seriously fast Wordpress performance that consumes incredible few system resources.
First, an ease of use feature that I discovered: someone did a build of PHP 5.3.8 for Ubuntu 10.04 LTS (2026: both reached end of life years ago). Since PHP 5.3 includes PHP-FPM, you can keep everything package based.2
To use these packages add these lines to /etc/apt/sources.list:
deb http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
deb-src http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
After updating the sources list, run this command to update the apt cache:
sudo apt-get update
(For more details on using these packages, as well as setting up a similar system, checkout this HowToForge article. In particular, there are some useful comments at the bottom.)
Anyway, one of the main features of this setup was swapping out the Apache web server for nginx and PHP-FPM. Like most PHP developers, Apache and mod_php has been the default setup for PHP applications for years. However, I can now vouch for the nginx/PHP-FPM combo as both stable and fast production environment. (I will try out this combo for development on my next PHP project to see how it works.)
Importantly, the system now uses a UNIX socket for the connection between the web and application servers rather than TCP/IP. That means that for the core application and web services there are two UNIX sockets used, one between the web server and the application server then again between the the application server and the database server (MySQL clients use the UNIX socket when the "localhost" host name is used or the host name is blank.)
Anyway, to really see the difference the architecture changes made, I used a blitz.io3 Rush to hammer the two instances.
First up was the old Slicehost system. This is the Rush configuration I used (same as Tumbledry):
--pattern 1-250:60 -T 4000 -r california
The result: this rendered the system completely unresponsive and required a hard reboot. Here's a shot of "top" before the system stopped responding. Note all the memory being consumed, load on the way up and lots of Apache processes:

Oh no! The system just died:

Next was the new Linode hosted solution. The result is that the new architecture sustained the Rush with virtually zero CPU usage (I'm not kidding) or any changes to memory usage. Varnish takes most of the load. (2026: Varnish does not speak HTTPS, so on a single server nginx's own fastcgi_cache now does this job with one less moving part.)

So as it turns out, I can also serve up 9 million hits per day from a small (512MB RAM), inexpensive ($20 per month) virtual server.
Here are the important configuration files:4
nginx.conf (gist)
user www-data;
worker_processes 5;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_comp_level 1;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
## PHP-FPM service
upstream backend {
server unix:/var/run/php5-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx virtual host config (gist)
server {
listen 8080;
server_name foo.com www.foo.com;
root /var/www;
index index.php;
access_log /var/log/nginx/foo.access.log;
error_log /var/log/nginx/foo.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
## Parse all .php file in the /var/www directory
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass backend;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
# BEGIN W3TC Browser Cache
gzip on;
gzip_types text/css application/x-javascript text/x-component text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
# END W3TC Browser Cache
# BEGIN W3TC Minify core
rewrite ^/wp-content/w3tc/min/w3tc_rewrite_test$ /wp-content/w3tc/min/index.php?w3tc_rewrite_test=1 last;
rewrite ^/wp-content/w3tc/min/(.+\.(css|js))$ /wp-content/w3tc/min/index.php?file=$1 last;
# END W3TC Minify core
}
php5-fpm.conf (gist) (2026: PHP 5 naming; the settings carry over to PHP 8, the file names and paths do not)
[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
[www]
listen = /var/run/php5-fpm.sock
user = www-data
group = www-data
pm = static
pm.max_children = 10
varnish (gist)
NFILES=131072
MEMLOCK=82000
INSTANCE=$(uname -n)
DAEMON_OPTS="-a YOUR_IP_ADDR:80 \
-T localhost:6082 \
-f /etc/varnish/wordpress.vcl \
-S /etc/varnish/secret \
-s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
wordpress.vcl (varnish site config) (gist) (2026: written for the Varnish of 2011; version 4 renamed req.request, vcl_fetch and error, so this will not load on a current release)
backend default {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"localhost";
}
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return(lookup);
}
if (req.url ~ "^/$") {
unset req.http.cookie;
}
}
sub vcl_hit {
if (req.request == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
error 404 "Not in cache.";
}
if (!(req.url ~ "wp-(login|admin|comments-post)")) {
unset req.http.cookie;
}
if (req.url ~ "^/[^?]+\.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.*|)$") {
unset req.http.cookie;
set req.url = regsub(req.url, "\?.*$", "");
}
if (req.url ~ "^/$") {
unset req.http.cookie;
}
}
sub vcl_fetch {
if (req.url ~ "^/$") {
unset beresp.http.set-cookie;
}
if (!(req.url ~ "wp-(login|admin|comments-post)")) {
unset beresp.http.set-cookie;
}
}
Notes
Added in 2026.
- Slicehost was a virtual private server host, where this site ran on a small "slice" until the move described here. Rackspace had bought it in 2008 and later folded it into its own cloud, and slicehost.com no longer answers. The site as it looked in September 2011 is in the Wayback Machine. ↩
- The package archive still answers, but Ubuntu 10.04 and PHP 5.3 both reached end of life years ago. Do not build on them. ↩
- blitz.io was a hosted load testing service. A "Rush" ramped simulated visitors up against a URL from a chosen region and charted response times, errors and timeouts, which is where the graphs below came from. The service has since shut down; loader.io is a current equivalent. The site as it looked in September 2011 is in the Wayback Machine. ↩
- The configuration files here differ from the 2011 originals, which the gist links still show. Corrected in the nginx virtual host:
try_files $uri = 404had a stray space and is now=404, and the PHP location matched.php$with an unescaped dot. Corrected in the Varnish rules:Set-Cookiewas stripped from the reply to a posted comment, so commenters were never remembered, and the static file pattern had an unescaped dot and matched only one character of a query string. Removed: three blocks whose only job was to add anX-Powered-Byheader advertising the caching plugin and its version, the last of them cut off mid-line in the gist. In the text,/etc/apt/sources.lstwas a typo forsources.list. ↩