#81 Single Code Base Install

Steve Cleveland

I am running a series of MRBS calendars. One of the
challenges I will be facing is upgrades. I'd like to
have the ability for a single code base install (ie,
Have it installed in one directory with multiple web
site on the same server pointing at it) Then when it
comes time to upgrade, I only have to upgrade one
install point.

I really like the way Drupal does it. They have a
sites directory with a specially named directory for
each site base on the $_SERVER['HTTP_HOST']. So if the
install site is http://test.com/test/mrbs, the
directory name would be test.com.test.mrbs and it would
have the config.inc.php inside of that. It also
searches for test.com.test and test.com. If it doesn't
find a match, it looks in a directory called default.

I spent a few minutes and got it to work pretty easily
with MRBS. I created a file called bootstrap.inc and
copied the contents of that file in Drupal to it (just
changed the "if (file_exists" line):

function conf_init() {
static $conf = '';

if ($conf) {
return $conf;

$confdir = 'sites';
$uri = explode('/', $_SERVER['PHP_SELF']);
$server = explode('.', rtrim($_SERVER['HTTP_HOST'],
for ($i = count($uri) - 1; $i > 0; $i--) {
for ($j = count($server); $j > 0; $j--) {
$dir = implode('.', array_slice($server, -$j)) .
implode('.', array_slice($uri, 0, $i));
if (file_exists("$confdir/$dir/config.inc.php")) {
$conf = "$confdir/$dir";
return $conf;
$conf = "$confdir/default";
return $conf;

I then copied my working config.inc.php to
sites/default and changed the config.inc.php in the
root directory to this:

include "bootstrap.inc";
$conf = conf_init();
if (is_readable("$conf/config.inc.php")) {
include "$conf/config.inc.php";


I've been able to create the appropriate site
directories and linked three sites (just using a soft
link in the file system) to the same install.

I realize using config.inc.php in the root for this is
probably not the best, but it worked for my purpose.

Please consider adding this feature.



Cancel   Add attachments