I’ve moved my wordpress blog from a hosted account on godaddy.com to a server that’s running lighttpd on ubuntu. The move was more complex than I expected, so I thought I’d share some details for others…
- I already had lighttpd installed, but I followed these instructions to add php support to lighttpd: Lighttpd+PHP – Ubuntu Wiki.
- I followed these great instructions for installing wordpress: Installing WordPress 3.0 on Ubuntu 10.04…
- I used wordpress import/export to export my data from the old wordpress install. The old install was version 2.8, but the file imported just fine into wordpress 3.0. Here are some good instructions from wordpress.com: Moving a Blog.
- I had to install all the plugins I wanted on my new install. This required my wordpress install be owned by the
www-datauser, which lighttpd is installed as. I did asudo chown -R ww-data:www-dataon the install directory. - I migrated my links from the old wordpress install using the instructions from wordpress.com: Import-Export Links.
- Make index.php the 404 handler, i.e.
server.error-handler-404 = "/index.php"per Setting up a WordPress Blog on lighttpd. - Add rewrite rules so that most urls in / gets handled by index.php per URL Rewriting for WordPress and lighttpd.
- Update the permalink settings to use
/%year%/%monthnum%/%postname%/
In the end, my lighttpd config looks something like:
$HTTP["host"] == "www.crobak.org" {
server.document-root = "/var/www/www.crobak.org"
server.error-handler-404 = "/index.php"
url.rewrite-final = (
# Exclude some directories from rewriting
"^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
# Exclude .php files at root from rewriting
"^/(.*.php)" => "$0",
# Handle permalinks and feeds
"^/(.*)$" => "/index.php/$1"
)
}
I’ve also switched to the awesome new Twenty Ten 1.1 Theme by the WordPress team.
Pingback: Per’s Page » Blog Archive » Wordpress on lighttpd with pretty permalinks
Joe,
Thanks for sharing this method (and the links also above).
I have been using this setup for some time, and started to play around with it in order to understand what it does. In essence, it looks to me as if you list two ALTERNATIVE methods for making wordpress work with lighttpd and pretty permalinks.
The first one (step 6 as in http://chrisjohnston.org/tech/setting-up-a-wordpress-blog-on-lighttpd) essentially uses a 404 error handler; if a file exists it will be called/loaded directly, otherwise /index.php will be called to handle it.
The second method (step 7 as in http://emil.haukeland.name/webservers/2010/url-rewriting-for-wordpress-and-lighttpd/) does pretty much the same thing explicitly; only it lists the files that it believes exists and allows those to be called directly and otherwise calls /index.php with the rest of the parameter string. So if you use this method, the 404 error handler should not be called in order to rewrite using the /index.php handler.
The first method does not work for me, though, if using plugins that require parameters to be passed via pretty permalinks. And the second one needs to have all other files you may want to give access to listed explicitly (google tracker files, favicon, other subdirectories or installations).
I’ve added a few more details on this on my blog also (http://www.b4net.dk/?p=214).
Pingback: raspberry pi, lighttpd and wordpress pretty permalink | Rants, grunts and chants