Multiple sites, one installation

Post about your customizations to share with others.

Moderators: Developer, Contributor

cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Multiple sites, one installation

Post by cas »

How to serve multiple mantis installations on the windows platform with :
1. just one mantis installation
2. one or more databases

There are 6 areas to take into account:
1. Sources
2. Database
3. Configuration
4. Attachments
5. Scheduled tasks
6. Updating mantis

1. Sources:
For all installations, sources go in one(1) place.

2. Database:
This is a no-brainer, do what ever you like, combine the DB or use seperate ones, just have it reflected in the correct config file.

3. Configuration:
The various Mantis installations should all point to the same directory, each having their own hostheaders.
Based upon the hostheaders the correct config file can be selected within the normal config_inc.php (see sample below).
Configuration of each installation, remains the same. All is handled in a dedicated config file.

4. Attachments:
Clearly per installation a seperate file location should be defined in case these are stored using DISK of FTP.
Handled in the specific config and within the project definition within each installation.

5. Scheduled tasks:
For each task a unique script need to be created per installation.
Suppose you have a script reading the email called read_email.php and you have mantis1 and mantis2 installed,
you need to copy the default script to read_email_mantis1.php and read_email_mantis2.php.
So for each installation you now can run the script in isolation and still have the option to select the correct config.

6. Updating mantis
As always , prepare a backup.
Next step is follow the default update instructions.
So copy all new sources etcetera
Final step is within each installation to run the update script
That is all

So how would your config_inc.php look:

Code: Select all

<?php
// ******************************************************************************************
// *                                                                                        *
// * HTTP_HOST is used to determine the config file needed for webservices                  *
// * SCRIPT_NAME is used to determine the config file needed for commandline services       *
// *                                                                                        *
// ******************************************************************************************

if (isset($_SERVER['HTTP_HOST'])) {
	if ($_SERVER['HTTP_HOST'] == "mantis1.yourdomain.com") {
		include('config_mantis1.php');
	}
	if ($_SERVER['HTTP_HOST'] == "mantis2.yourdomain.com") {
		include('config_mantis2.php');
	}
} else {
	if (isset($_SERVER['SCRIPT_NAME'])) {
		if ($_SERVER['SCRIPT_NAME']=="read_mail_mantis1.php") {
			include('config_mantis1.php');
		}
		if ($_SERVER['SCRIPT_NAME']=="read_mail_mantis2.php") {
			include('config_mantis2.php');
		}
	}
}
Clearly the above script can be optimised using php - switch like :

Code: Select all

<?php
// ******************************************************************************************
// *                                                                                        *
// * HTTP_HOST is used to determine the config file needed for webservices                  *
// * SCRIPT_NAME is used to determine the config file needed for commandline services       *
// *                                                                                        *
// ******************************************************************************************
$hostheader = $_SERVER['HTTP_HOST'];
$mailscript = $_SERVER['SCRIPT_NAME'];

switch ($hostheader) {
  case "mantis1.yourdomainl.com" :
     include('config_mantis1.php');
     break;
  case "mantis2.yourdomainl.com" :
     include('config_mantis2.php');
     break;
}

switch ($mailscript){
  case "read_mail_mantis1.php" :
     include('config_mantis1.php');
     break;
  case "read_mail_mantis2.php" :
     include('config_mantis2.php');
     break;
}
The contents of config_mantis1.php and config_mantis2.php is the normal config for each individual installation of mantis.
Mauzi
Posts: 1
Joined: 08 Feb 2011, 16:09

Re: Multiple sites, one installation

Post by Mauzi »

Excellent, this is very helpful. Thanks.
goodnutrition
Posts: 1
Joined: 09 Feb 2011, 05:56
Location: USA
Contact:

Re: Multiple sites, one installation

Post by goodnutrition »

Thanks for the codes. This really helps.
Phileas
Posts: 29
Joined: 22 Feb 2010, 16:51
Location: Switzerland

Re: Multiple sites, one installation

Post by Phileas »

We should collect such topics in a wiki !
There are more topics, such as sending emails ..., that should be written in a wiki.

Thanks for this tutorial
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Multiple sites, one installation

Post by cas »

There is a mantis wiki, http://mantisbt.org/wiki which also holds a variety of How To's.
Will see if this one fits on there.
Phileas
Posts: 29
Joined: 22 Feb 2010, 16:51
Location: Switzerland

Re: Multiple sites, one installation

Post by Phileas »

You are right. I know this wiki, but who has write access? How can we help to maintain the content?
i think this community has a lot of know how about mantisbt, but i miss a simple page or even better a wiki where we can collect the most misconfiguration and write a good guidance for setup mantisbt to unexperienced users.

Greetings
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Multiple sites, one installation

Post by atrol »

Phileas wrote:You are right. I know this wiki, but who has write access? How can we help to maintain the content?
If you are logged in at http://www.mantisbt.org/bugs there is a link Wiki
http://www.mantisbt.org/wiki/doku.php
Please use Search before posting and read the Manual
Phileas
Posts: 29
Joined: 22 Feb 2010, 16:51
Location: Switzerland

Re: Multiple sites, one installation

Post by Phileas »

ok. I could normally not get logged in directly in the wiki. After login the bugtracker it works.
That is not the way i usually login.
Is there any way to upload some pictures like in mediawiki? Pictures say more than words. :wink:
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Multiple sites, one installation

Post by cas »

Yes I can login to the Wiki and make changes but I am not allowed to create a new page :(
Phileas
Posts: 29
Joined: 22 Feb 2010, 16:51
Location: Switzerland

Re: Multiple sites, one installation

Post by Phileas »

i have the same behavior
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Multiple sites, one installation

Post by atrol »

This is the documented behaviour from http://www.mantisbt.org/wiki/doku.php
The current settings allow logged-in users to contribute to already existing pages. If you think a page is needed to cover a specific topic, please add your suggestion to Wanted Topics.
Please use Search before posting and read the Manual
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Multiple sites, one installation

Post by cas »

Added my proposal there. Already made the link on the Recipe page so as soon as the page is there, I will add the tutorial :mrgreen:
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Multiple sites, one installation

Post by atrol »

Please use Search before posting and read the Manual
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Multiple sites, one installation

Post by cas »

Thank you, page also updated :D
Phileas
Posts: 29
Joined: 22 Feb 2010, 16:51
Location: Switzerland

Re: Multiple sites, one installation

Post by Phileas »

great.
@cas: is it ok if i beautify the article without changing the content?
Post Reply