Drupal Multisite System | An Easy Way To Install a Multisite Drupal

I have a confession to make – Drupal multisite had been quite a mystery to me!

I failed to really grasped the concept, at least until recently.

DrupalUp to now, I have been building perhaps more than 30 sites and my favorite platforms were mainly Drupal and WordPress. I also moved my webhosting four times and doing new installations on a new server has taught a lesson or two. Thankfully, by time and lots of playing around with cPanel, installing, de-installing and so on, has put my understanding of the whole thing to a new level than when I first started.

And.. I was finally able to crack that little Drupal multisite code ‘secret’

It seems that the answer to my old puzzle lies in correctly using cPanel’s “Addon Domain” feature. Some techies advised against using cPanel but I am completely happy with it as it posed no problem up until now. The best part is – it’s easy and it works and suits almost everyone!

During my struggle, I looked at every other places and most will tell you to do something with .htaccess file and symlinks. I didn’t find fiddling with those stuff amusing. If one or both of these sounds Greek to you too, then worry not as I have discovered an absolutely simpler solution which I’ll share now.

So how could cPanel help?

In short, here’s what I did in a few steps:

  1. Create a folder named “drupal” under public_html e.g. “/public_html/drupal”. Basically you can name it anything and locate it in any folder you like. Just keep that in sync with step 2 and 3 below.
  2. Upload all your Drupal installation codes into the “drupal” folder.
  3. Create a folder under “drupal/sites/” to represent the URL of your domain. This is standard across Drupal multisite setup. If your domain for e.g. is “mydomain.com”, then create a folder that looks like “/sites/mydomain.com”. Put a fresh copy of “settings.php” from Drupal install into this folder. You may leave the configuration as it is as it will be filled by Drupal when you initiate installation later.
  4. Have your mySQL database ready or create one if necessary.
  5. In cPanel, create an Addon Domain and assign document root as “/public_html/drupal” or whatever you have defined earlier. All this does is that any access to the URL will end up being routed to “/public_html/drupal” folder. This is correct as Drupal codebase resides in there. (Note: Your primary or main domain i.e. the one you used to create your account with the webhost won’t be able to run Drupal in this way. That is because the main domain are not allowed to be ‘forwarded’ as it will disturb the whole setup. If your primary domain needs to run on Drupal, then all other ‘Drupal’ domains can be setup as ‘parked domain’ or ‘add-on’ ones and define sub-domain as “/public_html” only). Also if your cPanel require FTP username and password, put in anything you like as they are not related to Drupal install.cPanel-add-on-domain-drupal
  6. In your browser, enter the site URL. Drupal installation shall begin as usual.

Just repeat steps 3 to 5 above for as many sites as you have.

How It Works

As you can see, all domain URLs will end up at the same place i.e. “public_html/drupal”. However Drupal can tell the actual folder by looking at the URL entered and compare with domain name(s) defined in “drupal/sites/<domain name>” folder. So each URL will go to its’ own folder to do whatever it was supposed to do.

Setting up sub-domain as part of a multisite configuration is no different than that of the top level domain. I described a similar process in this post.

You may choose to use a common database shared across all your Drupal sites or otherwise - but that is another topic altogether.

As for myself, I only maintain a single set of Drupal codes for all of my Drupal sites. This makes my life a lot easier especially when it’s time to do updates, upgrades or even moving webhost.

On a different topic, I also run my WordPress sites using a single WP codes too. I shared how I did it in another article here. So I am like having two control centers where I manage all my Drupal and WP sites no matter how many of them. Adding a few more as I go along is a breeze. Life can’t be better than that, or can it?

Hope this helps you or someone out there. Enjoy.

Related Articles:

1. Stephen On Drupal: How to Correctly Set up Drupal Multisite?

2. Getting Started with Drupal: A Comprehensive Hands-On Guide

3. 22 Excellent Tips for New Drupal Developers

1 comment

11
Apr

Dear obwan This is the best help i found multisite with single drupal code, after many days of search rgds Tejbir