Sunday, March 29, 2009

Multiple sites, one database, shared part of tables

Multiple sites, one database, shared part of tables

剛剛有挖到一些東西,我可以 有 multiple-sites (multiple-domains) ,用 同一個 system (php scripts),用同一個 database,然後 選擇性的 "共用" 或 "獨立" database 裡面的 tables

例如說,我有十個網站,每個網站要顯示出來的 樣子 (theme) 不一樣,區塊 (block) 也要不一樣, 模組(module) 也要不一樣,但想要 share 相同的 user ,和 share 相同的 文章

有這樣需求的話,用 drupal 可以辦到


The proper methodology here
Lyal - March 29, 2007 - 21:44
The proper methodology here depends on your needs. How much variability are you expecting per site? Different content on each? If not, use drupal prefixing in a different way than you are currently using it, specifying main_ for the vast majority of the tables. Each domain would have a custom system group, and as many other tables as each individual domain will need to be unique from the others.. Something like:

$db_prefix = array(
'default' => 'main',
'system' => 'site37_',
);

You would then have to create system table with the site37 prefix.

The above isn't meant to be a full example, but using this method means that you can support many installs with different themes for each. If you wanted unique nodes, you would have to also include all of the tables that are necessary for node delivery (node, node_revision, sequences, etc).

Lyal,


Hmmm
kbahey - March 22, 2007 - 13:58
Seems like we have a link farm or something.

Anyways, Drupal can do this for sure. All you need to do is use the same $db_url for all the domains, and it will point to the same database. However, there are things that will be the same for all sites (e.g. site name, footer, theme, ...etc.).

You can even make it simpler by having a sites/default/settings.php that has a $db_url but NO $base_url, and point all the domains to the directory that has the index.php file in it.
--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

http://drupal.org/node/130021

No comments: