Multisite (Teamsite) Configuration

How to have multiple sites using the same codebase

Created by: Stephan Borg, Last modification: 27 Feb 2005 (04:42 UTC)
The following is used when you want to create multiple bitweaver sites using the same install, but possibly different databases.

A simple kernel/config_inc.php looks something like this:
{CODE()}<?php
global $db_tiki, $host_tiki, $user_tiki, $pass_tiki, $dbs_tiki;
$db_tiki = "pgsql";
$host_tiki = "localhost";
$user_tiki = "tiki";
$pass_tiki = "mypasswd";
$dbs_tiki = "mydb";
define( 'TIKI_DB_PREFIX', '' );
define( 'TIKI_ROOT_URL', '/bitweaver/' );
?>{CODE}

This allows a single configuration for the code base. If we would like to have other configurations, we would have to add some smarts to the kernel/config_inc.php, so that it can redirect each request appropriately.

Imagine we have two sites setup using virtual hosting, site1 and site2. We can configure config_inc.php as follows:
{CODE()}<?php
global $db_tiki, $host_tiki, $user_tiki, $pass_tiki, $dbs_tiki, $tikidomain;
$db_tiki = "pgsql";
$host_tiki = "localhost";
$user_tiki = "tiki";
$pass_tiki = "mypasswd";
$dbs_tiki = "mydb";
define( 'TIKI_ROOT_URL', '/' );
switch ($_SERVER"HTTP_HOST") {
case "site1":
define( 'TIKI_DB_PREFIX', 'site1.' );
$tikidomain = "site1";
break;
case "site2":
define( 'TIKI_DB_PREFIX', 'site2.' );
$tikidomain = "site2";
break;
}
}
?>{CODE}

As mentioned on the ((bitweaver and ((bitweaver and ((bitweaver and ((bitweaver and ((bitweaver and ((bitweaver and ((bitweaver and ((bitweaver and bitweaver and TikiWiki Page http://tikiwiki.org/AkiraMultiTiki - you can use a similar method without using virtual hosting. I haven't tried this yet, but the coding would look something like this.
{CODE()}<?php
global $db_tiki, $host_tiki, $user_tiki, $pass_tiki, $dbs_tiki, $tikidomain;
$db_tiki = "pgsql";
$host_tiki = "localhost";
$user_tiki = "tiki";
$pass_tiki = "mypasswd";
$dbs_tiki = "mydb";
switch ( extractTopPath( $SCRIPT_URL ) ) {
case '/site1/':
define( 'TIKI_DB_PREFIX', 'site1.' );
define( 'TIKI_ROOT_URL', '/site1/' );
$tikidomain = "site1";
break;
case "/site2/":
define( 'TIKI_DB_PREFIX', 'site2.' );
define( 'TIKI_ROOT_URL', '/site2/' );
$tikidomain = "site2";
break;
}

function extractTopPath( $in ) {
if ( ( $point = strpos( substr( $in, 1 ), "/" ) ) === false ) {
return ( $in . "/" );
} else {
return substr( $in, 0, $point + 2 );
}
}
?>{CODE}

Comments

User Multisite

by William Leibzon, 08 Mar 2005 (16:15 UTC)
I've started workin on multisite, quite possible some of what you showed above would be used. But when talking about multisite, I actually meant something more then just sharing websites on one server with static configuration. The multisite I want would be user-specific, with each user being allowed to have the content the user creates being available as part of one or more sites. The list of sites that user can make the content available on, would be configurable by admin, possibly on per-group basis.
  Page 1 of 1  1