Tuesday, January 18, 2011

Wordpress Mu with Lighttpd and Multiple Domains

wordpressI’ve been using the Bloog blogging software that runs on Google App Engine now for about a year at mindby.com.  One thing I’ve noticed is the performance of Google App Engine + Bloog is unpredictable.  This is apparently due to the loading and unloading of the application in the Google infrastructure + probably some inefficiencies in the Bloog platform as it relates to AppEngine.  Don’t get me wrong I love the simplicity and elegance of the Bloog platform and its REST based architecture, but at this point I’ve grown frustrated with performance and am moving on. After a brief look at a few open source platforms and hosting providers I’ve settled on Slicehost and Wordpress MU.  I decided to host the Wordpress installation at Slicehost because I’m a bit of a techie and will undoubtedly find myself wanting to do more than allowed at Wordpress.com.  I also used MU instead on the regular Wordpress install because I wanted a little more flexibility in the future to host multiple blogs if necessary.
SliceHost doesn’t offer my preferred Linux distro of openSUSE so I had my choice between Ubuntu, Fedora and Debian Lenny.  I’ve always been a fan of the stability of the Debian platform so I opted to use Lenny as my platform.  I went with the smallest slice I could rent which is 256MB 10G and 100G of bandwidth which should be plenty if I’m careful.  I also checked with Slicehost on upgrading if necessary and they assured me upgrades where only a click away.
Anyhoo, due to the smallish nature of my slice I wanted to run lighttpd instead of Apache and because I will probably host multiple blogs over time I went ahead and decided to configure Wordpress MU for multiple domains from the very get-go.  What I found was that even with Google and the awesome Wordpress installation tutorial there was still some “head scratching” I had to do to get things up and going.  Thus this tutorial was born to help others who may be doing a similar thing.
After getting my brand new Slicehost VM and configuring it for ssh key access only I went about configuring Wordpress Mu and lighttpd.
  • Install the following using apt-get
  1. Install mysql-server
  2. Install lighttpd
  3. Install php5, php5-cgi, php5-mysql, php5-gd (this installed apache2 which I promptly removed)
  • Download Wordpress Mu
  • Install wordpress-mu into /var/www/ and copy the contents of the unarchived directory to /var/www.  You could also rename the directory to something like wpmu if you want but these directions assume you’ve copied everything into the webserver’s root
  • Create /etc/lighthttpd/wpmu-rewrite.conf with
server.error-handler-404 = “/index.php”
url.rewrite-once = (
“^/(.*/)?files/$” => “/index.php”,
“^/(.*/)?files/(.*)” => “/wp-content/blogs.php?file=$2″,
“^(/wp-admin/.*)” => “$1″,
“^/([_0-9a-zA-Z-]+/)?(wp-.*)” => “/$2″,
“^/([_0-9a-zA-Z-]+/)?(.*\.php)$” => “/$2″,
)
  • Modify /etc/lighttpd/lighttpd.conf and add the following making sure to change domain.com to your domain…
$HTTP["host"] =~ “domain\.com” {
simple-vhost.default-host = “domain.com”
include “wpmu-rewrite.conf”
}
  • Copy /etc/lighttpd/conf-available/10-fastcgi.conf to /etc/lighttpd/conf-enabled and restart lighttpd
  • Create MySQL database called ‘wpmu’
  • Change the permissions of a couple of directories before the next step withchmod 777 /var/www and /var/www/wp-content
  • Open a browser at http://yourdomain.com/wp-admin/install.php and configure the database.  Alternatively you could copy /var/www/wp-config-sample.php to /var/www/wp-config.php and make the necessary changes manually using the Famous 5 Minute Install Guide
  • You’ll need to change permissions on a couple of directories if you run install.php (but remember to change them back to 755)
chmod 777 /var/www and /var/www/wp-content
  • You’ll also have to use subdomains in your configuration if you want to host multiple domains via the installation
  • Restart lighttpd and login at http://domain.com/
At this point you should have main Wordpress Mu running and accessible, however the next thing on my list was getting the multi domain stuff working.   For this do the following…
  • Install the multi-site plugin
  1. Download from http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/
  2. Extract the archive
  3. Copy sunrise.php into wp-content/. If there is a sunrise.php there already, you’ll just have to merge them as best you can.
  4. Copy domain_mapping.php into wp-content/mu-plugins/.
  5. Edit wp-config.php and uncomment the SUNRISE definition line: define( ‘SUNRISE’, ‘on’ );
  6. As a “site admin”, visit Manage->Domain Mapping to create the domain mapping database table and set the server IP address.
  7. Ensure the plugin is activated from Domain Mapping plugin under “Plugins” in the Site Admin site
  8. Make sure the default Apache virtual host points at your WordPress MU site so it will handle unknown domains correctly. Do this by ensuring that you have a “*” record pointing to your installation’s IP address at your domain registrar.
  • Once installed you will have the Domain Mapping option under tools as a Site Admin
  • TRICK:  Do NOT configure any new domains from the Main Site Administration console (ie. the one you configured during installation)
  • Go the Main site admin console
  • Create a new blog and make sure you use subdomains (you will need to configure a wildcard at your DNS service provider for this)
  • Browse to the newly created page and Login as the administrator for the subdomain
  • In the sub-site’s admin console go to Tools -> Domain Mapping and map your new domain
  • For each new domain you add you should modify the lighttpd.conf file as shown above for each new domain.  You do not need to add additional wpmu_rewrite.conf files, only $HTTP["host"] section of lighttpd.conf
So that’s it.  It really doesn’t take very long but like I mentioned some of these instructions were on various websites and needed to be condensed into one tutorial.  Hope it works and look for my transition to the Wordpress platform soon  .  If this doesn’t work for you or you discover other tips and tricks please leave a comment so everyone will know.

0 comments:

Post a Comment

 
Design by GURU