Monthly Archives: August 2005

Drupal Trick: Multiple Subdomains, One Database

Note: This post is from 2005, I’m not sure what, if anything, is still relevant.

Drupal is an opensource content management system that runs on PHP+MySQL with a flair for community created content, and a robust developer community that offers a lot of capabilities “out of the box,” and even more by adding community-developed modules. I think I first encoutered it a year or two ago, but really started investigating it a few months ago to support a few projects for my employer and since then I’ve been giving it strong consideration for some personal projects as well.

For the past day and a half I’ve been trying to figure out a good way to use Drupal to manage a collection of sites while minimizing administrative overhead.

The worst case is to install a copy of drupal for each site, along with a separate MySQL database for each site. This isn’t difficult, it probably only takes 10 minutes or so per site, but it hurts my brain to think of doing 10 or 15 sites that way because it means maintaining a separate set of users for each and it means that content can’t easily be shared between sites.

Slightly better is to take advantage of Drupal’s ability to have multiple installations use a single database while sharing certain tables between installations, specifically the table of users. This approach reduces some of the administrative overhead, but still has potential problems for sharing content and the like.

Of course, one can go even further with this approach, and share content tables. Unfortunately, it gives me a headache thinking about what would be shared and what would need to be unique to each installation. It also requires tweaking of the install scripts for each new installation. Getting it repeatably correct probably requires creating custom config scripts, and frankly, I don’t have the skills to write them before my lazyness takes hold.

Of course, sharing content tables doesn’t necessarily solve the whole problem anyway, because, by my estimation, once you share enough of the database between multiple installations, you loose the ability to make the sites appear notably different, at least in terms of the content they display.

What I really wanted was an easy way to have a single drupal installation, and then show a different home page to the user depending on the domain name they used to access it. I figured I could use Drupal’s powerful taxonomy features to identify which domains/sites a given piece of content should appear on, but I wasn’t sure how to make it appear properly on the front page of the individual sites. There are suggestions for redirecting a subdomain to a particular page using Apache mod_rewrite, but if I read things right, this results in the loss of the original host name.

I went digging through the drupal site for options. I found a number of people looking to do similar things, and I noticed that future versions of Drupal may have Publish-Subscribe functionality that will be useful for this sort of application, but I didn’t find a real solution for right now that wasn’t going to require more custom coding that I was comfortable with doing myself.

Then I hit upon the solution. Drupal lets you host multiple sites off a single copy of the code by setting up separate settings files for each installation (2nd half of step #4). Drupal lets you configure the default homepage for each site. Usually this is stored in the database, but it can be overridden in the settings file. The solution is to put the two togeather. Make a copy of the main settings file for each site and override the home page to point to a taxonomy view filtered by the category used to flag the content. Now try it out. It seems to work.

So, step by step:

# Install Drupal
# Create a vocabulary that designates where content should appear and enable it for all the content types you want to share between sites (look under “adminster:categories”). If you want content to appear on multiple sites, be sure to check the “multiple select” box.
# Add terms to the vocabulary for each target site.
# Set up DNS aliases for each additional site that points to the main site (I suggest a CNAME record).
# If necessary, configure apache to fulfill requests for the subdomains from the same document root as the main site. If you are using CPanel or another hosting control panel, you might have to “park” the additional domains.
# create copies of the main site’s settings.php (sites/default/settings.php) and place them in “example.com” and the additional site was “zinc.example.com” then you’d need to put a copy of the settings file in “sites/zinc.example.com/”. See the Drupal install instructions for detailed information on naming the directories properly.
# edit the settings.php file for each additional domain:
## Update @$base_url@ to match the name of the additional domain (@$base_url=’http://zinc.example.com’;@ for example).
## Override the front page: @$conf = array ( ‘site_frontpage’ => ‘section/zinc’,);@
# Save the file and try visiting the additional site.

_Note:_ I have installed the pathauto module which provides nice human readable URLs for pages, including taxonomy views. As a result, I can use “section/zinc” to designate the front page, rather than “taxonomy/x/y”. You could also do this by hand configuring things in the path module.

This approach isn’t perfect, but at least this gets me up and running and gives me something to build upon. I hope other people will find it useful as well.

I’d intended to cut bait on this at noon today, and didn’t figure out this little trick until after 5pm, but it’s satisfying to have figured it out.

Bit by Bit

Last week I mentioned that I’m “helping out with infrastructure”:http://www.geekfun.com/archives/000612.html to prepare for the release of the next Harvey Danger album. At the time, I could only hint at why it was important, but last week, “the band announced”:http://www.harveydanger.com/news/ that they will be releasing the album as free download on the net a couple of weeks after the CD goes on sale.

Today, “Jeff layed out more details”:http://jeffjlin.typepad.com/rock_and_roll_mcdonalds/2005/08/inching_ever_cl.html on how the release is going to work. In the coming weeks, expect to see more from Jeff on the thinking behind this bold move.

bq. Sept. 13 — Album (deluxe double-CD edition) released in stores
Sept. 20 — Electronic version of the album seeded to Bittorrent
Sept. 27 — Electronic version of album available for download from harveydanger.com

p. Until a week or so ago, I was viewing the Bittorrent as checklist item that would be cool and fun to do even though most people would end up using the web download, but now I’m pretty excited about it, especially since there will be a full week between the bittorrent release and the http release.

I’d intended to post more tonight about the considerations I’ve been working through to get the infrastructure planned and deployed, but its past my bedtime, so it will have to wait. So, come back here for more on the “How,” and keep an eye on “Jeff’s blog”:http://jeffjlin.typepad.com/ for the “Why.”

Mindmapping + OPML?

MindManager is a commercial mind mapping tool for Windows. They’ve recently published an article titled “Blog Better With MindManager”:http://blog.mindjet.com/2005/07/blog-better-with-mindmanager . I’m not sure I’m completely sold on mindmaps, but I like the idea, and they clearly work for some people. It would be interesting to see a bridge between MindManager (and other mindmapping tools like “FreeMind”:http://freemind.sourceforge.net/wiki/index.php/Main_Page) and the “new OPML stuff that Dave Wiener has been bootstrapping”:http://www.opml.org/.

Mindmaps are really just outlines expressed in a visually richer format.

Intel and Apple at the low-end

DigiTimes reports that “Intel may be leaving the entry-level chipset market”:http://www.digitimes.com/mobos/a20050803A1001.html. I don’t know anything about the source, but if this is true, I wonder what it means for Apple, who, it’s been assumed, is going to make ample use of Intel’s hardware platform offereings (including chipsets and motherboards) as part of their transition from PowerPC to Intel. The Mac Mini, with its extremely low price point, would seem to be left hanging if Intel exits this market segment, which would give other vendors their opportunity to get their foot in the door with Apple and establish a chance for moving upmarket at some point in the future.

bq. Intel plans to phase out its 865 and 915PL/GL chipsets in the fourth quarter and exit the entry-level chipset market, sources with motherboard makers revealed. Intel has only told some first-tier mobo makers and OEM clients about the decision, and the company is not expected to make a public announcement, the sources said.

via “Anandtech”:http://www.anandtech.com

*Update:* “According to news.com”:http://news.com.com/Intel+phasing+out+low-end+chipsets/2100-1047_3-5817118.html?tag=nefd.top , Intel denies that it is exiting the low-end of the market. On the other hand, it sounds like they may have a rather large gap between product generations at the low end of the line. The timing may not impact apple, but it could send system vendors elsewhere when shopping for components for the low end of their product lines. If true, it seems that Intel needs to work on their execution (once again).

But what about the clips, man?

Anandtech did a review of “4 Ultra-compact Digicams”:http://www.anandtech.com/digitalcameras/showdoc.aspx?i=2473&p=1 and, like just about everyone else, they paid absolutely no attention to the quality of the movies.

As I’ve written before, I think “ignoring the movie capabilities”:http://www.geekfun.com/archives/000588.html of the latest generation of digicams is a big mistake.

With their compact “go-anywhere” form factor and their ability to do 640×40 @ 30 or 60 frames per second for minutes at a time, they are a hell of a lot more handy than your average camcorder and reasonably competitive quality-wise.

Since my brother picked up one of the Canon SD400s, I’ve received many more clips of my nephews than in all the years they had a FireWire capable camcorder and they look pretty good too.

A camcorder will likely always have better low-light performance, better audio and a wider range of optical zoom, but I think the movie featuers on digicams are already more useful for most of the footage consumers capture.