Magento 1.8 – Single Installation with Multiple Databases

magento-1.8multistore

Is it possible to make one installation, and from this installation to make multiple shops with different databases?

Something like I will make one installation on domain.1 with a database, and from admin I will crate a new website and a store on some new database for domain.2.

I know that multiple stores can be achieved with one database. But can it be the same with different databases.

Best Answer

Great answer slarek. We did something very similar. Instead of editing index.php we setup separate folders outside of magento's codebase, and include mage.php from those folders, and then edit the etc_dir (and other dirs) like in your method above.

folder structure:

/www/client1
/www/client2
/www/client3
/www/clientX
/www/magento

Inside each of the client folders are:

  • /www/clientx/etc/local.xml (with unique database defined, and unique redis db)
  • /www/clientx/etc/modules (this is a sym link to /www/magento/app/etc/modules)
  • /www/clientx/index.php

in /www/clientx/index.php

define('MAGENTO_ROOT', '/www/magento');

...(rest of index.php is business as usual)...

$client = isset($_SERVER['CLIENT_ID']) ? $_SERVER['CLIENT_ID'] : '';] Mage::run($mageRunCode, $mageRunType, array('etc_dir'=>'../'.$client));

We set

$_SERVER['CLIENT_ID'] in Nginx with 
`fastcgi_param  CLIENT_ID clientx; `
Related Topic