Multisite On localhost Without Virtual Hosts
I've been putting off setting up multisite on my localhost for ages, mostly because in the past I've found getting Apache virtual hosts to work can be a bit tricky: not impossible, but the sort of thing where I could easily lose an hour on a minor thing I've forgotten to do. And after all, with a shiny new iMac and a hard drive whose proportions I can't even remember, why not just 'drush dl' all over again?
But I'm actually working on a multisite project at the moment, and suddenly getting this to work becomes more interesting than having another SVN copy of my code kicking around.
Given multisite can respond to subfolders, I was wondering if this could work when Drupal itself is in a subfolder, like this:
- webroot
-- drupal-1
-- drupal-2
-- drupal-multisiteTurns out it can. Suppose you want a new subsite called 'drupal-subsite'. Here's what to do in your webroot:
ln -s drupal-multisite drupal-subsite
cd drupal-multisite
mkdir sites/localhost.drupal-subsite
cp sites/default/default.settings.php sites/localhost.drupal-subsite/settings.php Your lolcathost(*) sees just another subfolder that's a site; the symbolic link sends you to the existing Drupal folder; and finally, the multisite system sees that you're browsing 'localhost/drupal-subsite' and selects the localhost.drupal-subsite folder as the one holding your site.
You can also have your subsite explicitly sit below the main site like this:
- webroot
-- drupal-1
-- drupal-2
-- drupal-multisite
--- drupal-subsiteIn which case your sites folder is localhost.drupal-multisite.drupal-subsite and the symlink should be inside the multisite folder:
cd drupal-multisite
ln -s . drupal-subsite
mkdir sites/localhost.drupal-multisite.drupal-subsite
cp sites/default/default.settings.php sites/localhost.drupal-multisite.drupal-subsite/settings.php So when I next get a moment I'll consolidate the various test sites I have, and when I have more than one patch on the go that I want to keep segregated, I can just add a multisite, get a fresh CVS copy of the code, and get going.
I've added details to the documentation too.
(*) yes, I keep typing it like that.


thanx
Yep it was helpful... helped me to setup multisite in a go.. :)
Here's a script for setting
Here's a script for setting up a subsite inside the current site folder:
#!/bin/bash
BASE=`pwd`
BASE=`basename $BASE`
echo "Setting up $1 as a subsite of $BASE."
ln -s . $1
mkdir sites/localhost.$BASE.$1
cp sites/default/default.settings.php sites/localhost.$BASE.$1/settings.php
Additional options
Other options include
1. Just run one multisite and put faks DNS settings in your /etc/hosts file
so i I run example.com in real life and want to have a test version on my machine, I add a line to /etc/hosts as follows
127.0.0.1 example.local
then in my sites folder make example.com folde
mkdir example.com
and symlink example.local to it
ln -s example.com example.local
Then hit example.local in your browser
2. Same as one but instead of /etc/host run your own DNS server:
http://geoffhankerson.com/node/108 (OS X)
or
http://groups.drupal.org/node/16862 (Ubuntu)
3. Do #2 and run Aegir http://groups.drupal.org/aegir-hosting-system
Post new comment