In my ventures with this new web server (and to host a new web site, duh!), I just set up WordPress behind nginx. It's really a piece of cake.
I pretty much just copy-pasted configuration snippets from the Nginx wiki:
http://wiki.nginx.org/WordPress
I stiched up the first and last blocks to have a WordPress Multisite (with subdomains) configuration that communicates to the PHP fcgi backend through a unix socket file:
server {
server_name host.name.com;
root /var/www/host.name.com; ## Your only path reference.
index index.php;
access_log /var/log/nginx/$server_name.access.log;
error_log /var/log/nginx/host.name.com.error.log; ## hmm $server_name doesn't work here
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
error_page 404 = @wp;
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
# Forbid PHP on upload dirs for security
if ($uri ~ "uploads") {
return 403;
}
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-cgi/php5.sock;
}
location ~ \.inc$ {
# Forbid PHP on upload dirs for security
if ($uri ~ "uploads") {
return 403;
}
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
# Redirect to files
rewrite ^(/[^/]+)?/files/(.+) /wp-includes/ms-files.php?file=$2 last;
expires max;
log_not_found off;
}
# For Multisite: Rewrite rules. Blog name must be removed. Corresponds
# to the rules that WordPress requires you to put in the .htaccess file.
location @wp {
# Redirect to files
rewrite ^(/[^/]+)?/files/(.+) /wp-includes/ms-files.php?file=$2 last;
# Match only one section
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
# Send everything else to index.php (permalinks)
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}
There's also a whole bunch of crazy rules on the wordpress site, but since I don't plan to use too much extensions on that new site, I'll keep things plain and simple.
oops, image files were not showing up right.
I found that there were two problems in the config, so I changed the article to correct those problems: