Sunday, March 29, 2009

Multiple sites, one database, *same tables*

Multiple sites, one database, *same tables*
Deprecated - Performance and scalability · Drupal 5.xdenver.root - March 22, 2007 - 08:11
Hello, I currently have a number of sites configured and running off of the same database, using different table prefixes for each site. All sites are also running off the same codebase, using Drupal's great site management abilities.

However, I am anticipating the addition of around 100 domains to my management within the next year or so, and I would really like to restructure things so that most of these sites are running off of the exact same tables, instead of the current setup where I am creating ~55 new tables for each additional site. As far as I know (my knowledge of Drupal is becoming relatively comprehensive), the Drupal core doesn't natuarally support transparently using the same set of db tables for multiple sites (esp. configuration data), and I am wondering if anyone has done this before, or has some good pointers.
Short of some goupy restructuring of Drupal's core, I haven't thought of a way to simply write a new module, add a table called something like "sites", and abbra-cadabra alter each and every db query to push and pull data based on site configuration; and I'm not sure where to go from here, except to maintain hope that something like this can be done.

If you have questions, feel free to let me know, and I will provide you with as much information as I can to help you see what I'm looking for!

» Login or register to post comments
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:

Login or register to post comments
I am a Drupal newbie, but
Sewdn - March 28, 2007 - 17:21
I am a Drupal newbie, but can't this be accomplished by using organic groups?

Evry new distribution uses a new organic group. On evry different site, you only show the view of the according organic group.

This way you can centrally manage the content of all the sites, uses general content that is used on evry site, use a central user-login, and make them contribute on all your sites...

Am i wrong here?
Isn't this the idea of the organic groups?

Hope this helps in some way...

Login or register to post comments
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).



Login or register to post commentsI was also looking for
freewill07 - April 8, 2007 - 05:44
I was also looking for knowing that.

Login or register to post commentsSo what was the outcome? I'm looking for the same thing
kappaluppa - August 3, 2007 - 21:29
I have five sites, on five domains. I'd like to have one central admin section that will allow me to change the content for any of the five sites from just one place. Some information will be the same, all sites will have a different theme.

No comments: