Drupal subsites made simple

The short story

Rather than trawling through my digressions I'll place the steps for setting up Drupal sub sites at the top of the post. I will demonstrate how I made http://typhonius.com a sub site of http://adammalone.net

  1. Point the DNS at the IP of the server.
  2. Ensure virtual hosts point to the Drupal web root of your pre-existing Drupal site.
    NameVirtualHost *:80
    <VirtualHost *:80>
      DocumentRoot /home/drupal/public_html
      ServerName adammalone.net
      ErrorLog logs/drupal-error_log
      CustomLog logs/drupal-access_log common
    <VirtualHost *:80>
      DocumentRoot /home/drupal/public_html
      ServerName typhonius.com
      ErrorLog logs/typhonius-error_log
      CustomLog logs/typhonius-access_log common
  3. Create databases for the sub sites.
    CREATE DATABASE typhoniussite;
    GRANT ALL PRIVILEGES ON typhoniussite.* TO 'typhonius'@'localhost' IDENTIFIED BY 'password';
  4. Create directories for the sub sites in the sites directory. (A useful tip is to make the directory names the same as the domain names)
    mkdir sites/typhonius.com
  5. Copy sites/example.sites.php to sites/sites.php
    cp sites/examples.sites.php sites/sites.php
  6. Alter sites.php and add in the directory names and associated domain names.   $sites['typhonius.com'] = 'typhonius.com';
  7. Copy sites/default/default.settings.php to sites/[site name]/settings.php
    cp sites/default/default.settings.php sites/typhonius.com/settings.php
  8. Navigate to newsubsitename/install.php and install your new subsite!

Hopefully these steps are reproduceable enough for another person and if not submit a comment and tell me why not!

The long story

I acquired a couple of additional domains a short while ago and as yet haven't decided what to do with them. I'm not just hoarding domains so perhaps desist from linking me to the next meeting of Domain Campers Anonymous. Like many who've spent a portion of their life online I have a pseudonym since being called by my real name online is just so uncool. This was the name I signed up to Drupal.org with.

Since typhonius.com was not in use I decided to nab it with the intention of making a simple one page site giving people a little bit of information about me with reference to that name. Until today http://typhonius.com simply pointed towards http://adammalone.net so anyone navigating there would end up on this site. I didn't feel a one page site deserved its own unique Drupal install and didn't feel much like making a web page from scratch so considered a Drupal sub site as the solution. This was twinned with the fact that although I've worked in Drupal installs which are sub sites ,I've not actually set one up before.

Enter the challenge

After looking online for a number of instructions in setting up sub sites from scratch I found nothing of immediate value. A little bit of intuition and looking through bootstrap.inc I worked out the methods detailed above which appeared to succeed. The advantage of running sub sites is twofold. Not only does it keep the codebase small (vital for a small server like mine), but as each site runs from the same core and contributed modules they only need to be updated once.

The code enabling sub sites in bootstrap.inc is elegant to say the least and I recommend people check out the conf_path function. Checking the current URL and matching against configuration in the sites.php file will alter the configuration path hence which settings.php the request uses.


Submitted by keiran (not verified) on

A theme like yours with a few simple tweaks would really make my blog shine. Please let me know where you got your theme.

Add new comment