Welcome Guest, Not a member yet? Register   Sign In
Separating Config Directory from Application?
#10

[eluser]Bas Vermeulen[/eluser]
Hi,

What I did to have multiple sites running on one install is the following:

- index.php
- .htaccess
- system
- application (including the config folder)
- site1
-- index.php
-- .htaccess
-- public
- site2
-- index.php
-- .htaccess
-- public

site1 and site2 come with just an index.php and a .htaccess file and a public folder with images and css files. In the index.php files you can set the location of the system and application folders. In the same index.php file you can also add config items, these will overwrite the config in the application/config folder:

/site1/index.php
Code:
$assign_to_config['base_url'] = 'http://localhost/site1';
/site2/index.php
Code:
$assign_to_config['base_url'] = 'http://localhost/site2';

To be able to use a custom database connection per site I added the following to the index.php files:

/site1/index.php
Code:
define('DB_GROUP', 'site1');
/site2/index.php
Code:
define('DB_GROUP', 'site2');

In the application/config/database.php I set:

Code:
$active_group = DB_GROUP;

Then you can add the connection groups in the same file:

Quote:$db['site1']['hostname'] = "localhost";
$db['site1']['username'] = "username";
$db['site1']['password'] = "password";
$db['site1']['database'] = "database";
$db['site1']['dbdriver'] = "mysql";
$db['site1']['dbprefix'] = "";
$db['site1']['pconnect'] = TRUE;
$db['site1']['db_debug'] = TRUE;
$db['site1']['cache_on'] = FALSE;
$db['site1']['cachedir'] = "";
$db['site1']['char_set'] = "utf8";
$db['site1']['dbcollat'] = "utf8_general_ci";
$db['site1']['swap_pre'] = "";
$db['site1']['autoinit'] = TRUE;
$db['site1']['stricton'] = FALSE;

I hope this is what you were looking for?


Messages In This Thread
Separating Config Directory from Application? - by El Forum - 09-13-2010, 07:06 AM
Separating Config Directory from Application? - by El Forum - 09-13-2010, 07:15 AM
Separating Config Directory from Application? - by El Forum - 09-13-2010, 08:29 AM
Separating Config Directory from Application? - by El Forum - 09-13-2010, 08:53 AM
Separating Config Directory from Application? - by El Forum - 09-13-2010, 09:00 AM
Separating Config Directory from Application? - by El Forum - 09-13-2010, 10:59 AM
Separating Config Directory from Application? - by El Forum - 09-14-2010, 08:09 AM
Separating Config Directory from Application? - by El Forum - 09-14-2010, 08:13 AM
Separating Config Directory from Application? - by El Forum - 09-14-2010, 10:56 AM
Separating Config Directory from Application? - by El Forum - 09-14-2010, 12:33 PM
Separating Config Directory from Application? - by El Forum - 09-16-2010, 08:35 AM
Separating Config Directory from Application? - by El Forum - 09-16-2010, 01:55 PM
Separating Config Directory from Application? - by El Forum - 10-13-2010, 01:57 PM
Separating Config Directory from Application? - by El Forum - 10-13-2010, 02:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB