One site, several instances

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
Chlewey
Posts: 4
Joined: 12 Apr 2011, 14:59

One site, several instances

Post by Chlewey »

I've read the forum "Multiple Sites, One Instalation" and the corresponding Wiki HowTo. Those articles do not address my problem.

I want to implement a site running several instances of Mantis Bugtracker, each one with its own customizations.

Currently I can manage that by using several installations of MantisBT, one for each instance, and having one database for each instance. I would like to have one installation and one database.

For one installation I have tried to use mod_rewrite at my Apache server:

Code: Select all

RewriteRule ^(instance1|instance2|instance3)/(.*)$ mantis/$2?site=$1 [PT,L,QSA]
and, at config_inc.php I use $_GET['site'] to personalize a few items.

This works for incoming links, however all internal links and redirecting use the real installation path. I would like not to do too much rewritting into the MantisBT code.

On the Database, I still do not know how to use one database. Somewere I read something about using prefixed tables, however I cannot find where to set the prefix variable.
Chlewey
Posts: 4
Joined: 12 Apr 2011, 14:59

Re: One site, several instances

Post by Chlewey »

I'm answering myself:

This is my config_inc.php

Code: Select all

<?php
	$get_site = isset($_GET['site'])? $_GET['site']: 'mantis';
	$get_imag = isset($_GET['site'])? $_GET['site']: 'images';

	# common configuration
	$g_hostname = 'localhost';
	$g_db_type = 'mysql';
	$g_database_name = 'bugtracker';
	$g_db_username = 'root';
	$g_db_password = '';

	# key part of the configuration
	$g_db_table_prefix = $get_site;		# using prefixed tables for each instance
	$g_path = "http://my.domain/$get_site/";	# using uris that the server will redirect
	$g_cookie_prefix = $get_site."bt";		# ensuring instances are kept separated

	# some branding
	$g_top_include_page = "$get_site/top_inc.php";
	$g_bottom_include_page = "$get_site/bottom_inc.php";
	$g_css_include_file = "$get_site/custom.css";
	$g_logo_image = "$get_imag/logo.gif";
	$g_favicon_image = "$get_imag/favicon.ico";
	
	# branding that is not automatic
	switch($get_site) {
	case 'instance1':
		$g_window_title = "The First Instance";
		break;
	case 'instance2':
		$g_window_title = "Instance Too";
		break;
	case 'instance3':
		$g_window_title = "Yet Another Instance";
		break;
	}
?>
The key part is redefining $g_path, $g_table_prefix, and $g_cookie_prefix. So far this seems to work.
Post Reply