28-Aug-06: Updated .htaccess code.
I was looking for a way to allow multiple blogs sharing the same installation. The setup I was looking for needed to have:
- The blog software installed in it’s own directory. Cluttering the root up with files is simply not a good idea. Separation of Concerns is a good thing at all levels.
- Have users access their blogs using nice memorable URL, and to have links within the blog use a clean URL format. Something like username.domain.com is friendly. This is not friendly: username.blogs.domain.com.
- I wanted to use other software on this domain, so I did not want to use or set a document root. Doing this pretty much prevents any other software being installed at the root level on that domain.
After failing to get Wordpress Multi-User (WPMU) to either install in it’s own sub-directory, or use clean URLs, I switched to Lyceum. Lyceum currently having the added benefit of being able to use most themes with no modification, and not creating a new set of tables for every user. Note, that both these products are in <em>beta</em>, so my experience should be taken with the view that things will change, and may be different when you read this.
I had spent around a week on-and-off, trying to get WPMU researched, and up and running I was prepared for a few days work doing the same with Lyceum. Turns out it took me less than an hour to do what I’d call a basic install, including research time. The Lyceum installation script was very clear. It was also accurate, which is an added bonus. Response from the user mailing list was amazingly prompt and helpful. Here’s what I now have:
- Users can access their blog via: username.domain.com
- Lyceum is installed in a directory (/lyceum) under root.
- Blog URL’s are clean. (Note, that so far login/logout url’s refer to my lyceum subdirectory. For me this is not a big deal. I was more concerned about URL’s that are typically bookmarked.)
In order for users to access their blogs via subdomain, you need to have a host that will setup wildcard sub-domains for you. Windows hosts cannot do this, and some *nix hosts will not do it, so submit a support ticket first. (I’m hosted with A Small Orange, and they turned on wildcards 5 minutes after my ticket was submitted.)
I basically followed the standard install procedure, with a few added steps. The following was done with Lyceum 0.33.
-
Turn on wildcard sub-domains.
-
The standard Lyceum directory structure has everything stored under src/lyceum. That seems needlessly long-winded, so I opted for the flat style structure. Basically I moved all subdirectories from under /src and put them inside /lyceum. I also needed to set permissions to 777, not 775/755 – not sure why this was.
/lyceum --> 777 wp-comments-post.php --> 777 /ajax /bin /config /installation /js /lib /smilies /system-admin /wp-admin /wp-content /blogs --> 777
-
Next, I renamed config/wp-config-sample.php to config/wp-config.php and updated values for:
define('DB_NAME', ''); // The name of the database define('DB_USER', ''); // Your MySQL username define('DB_PASSWORD', ''); // ...and password define('DB_HOST', 'localhost'); // hostname or IP of database server (possibly 'localhost') define('WEBROOT', '/lyceum'); define('MAINDOMAIN', 'lifehaiku.com'); define('SUBDOMAINS', true);
I also changed the URL format so that year and post-name are unique. For basic blogs, forming URLs based on date isn’t particularly clean, nor is it useful.
define('DEFAULT_PS', '/%year%/%postname%/');
-
Since I levelled out the standard Lyceum directory structure by moving everything out of /src, I set the sub-directory paths in private.php (just follow the comment in private.php):
define('PRIVATE_REL_PATH', './');
-
Next comes the running of the /lyceum/wp-admin/install.php installation script. Not as pretty as WPMU, but it works, and was easy to follow.
-
After a sucessful install, I created a .htaccess in my domain root to redirect requests to www.lifehaiku.com, and to redirect blog requests to the lyceum subdirectory. I’ll add new rules to accomodate other software on the domain in the future.
RewriteEngine On RewriteCond %{HTTP_HOST} ^www\\.(.*) RewriteRule ^(.*) http://%1/$1 [R,L] RewriteRule ^(.*) lyceum/$1 [QSA,L]
-
Some basic clean up involved removing the
/lyceum/wp-admin/install.php
script, and changing permissions on/lyceum
,/lyceum/wp-comments-post.php
, and/lyceum/wp-content/blogs/
to 755.
That’s it! My next steps were to create a blog for the admin user, and to install themes, and a few plugins and widgets.