21

I want to create a multisite with Drupal 7: Every site works separately but users, and nodes must be shared among the sites.

How do I achieve it?

3 Answers 3

17

You can change the settings for the access to the database that are contained in the settings.php file used by your Drupal site to something similar to the following one (replace the values between brackets with the correct values for your site):

$databases['default']['default'] = array(
  'driver' => '[Your database engine]',
  'database' => '[Your database name]',
  'username' => '[Your username for the access to the database engine]',
  'password' => '[The password for the access to the database]',
  'host' => 'localhost',
  'prefix' => array(
    'default'   => 'main_',
    'users'     => 'shared_',
    'sessions'  => 'shared_',
    'role'      => 'shared_',
    'authmap'   => 'shared_',
  ),
  'collation' => 'utf8_general_ci',
);
4
  • 1
    If I'm not wrong, this configuration is only useful if you have one database for different sites (And thus you have to provide prefixes). Is it possible to share user tables from different databases?
    – ccamara
    Commented Apr 2, 2012 at 14:35
  • 2
    @CarlosCámara you are incorrect, this solution uses the same database for all sites, but different table prefixes. So in the example above most tables will be prefixed with "main_", but the users, sessions, role and authmap tables will be prefixed with "shared_". For your additional sites, you will use a different prefix for 'default' (maybe 'site2_', 'site_3', etc.) but the same 'shared_' prefix. This information should probably be rolled into the answer.
    – Dalin
    Commented Jun 11, 2012 at 13:58
  • Hi, which line should I change to get users and profile? Commented Jul 3, 2012 at 14:35
  • 4
    Just to point out that when Dalin says Carlos is incorrect, Carlos is totally correct, as Dalin goes on to state exactly the same thing.
    – leexonline
    Commented Mar 27, 2014 at 9:32
10

Sharing users and content between different domains is what the Domain Access module is for. Essentially, it allows you to run multiple Drupal sites out of the same database, and share content.

When you install, enable, and configure the module, a new tabs shows up on the node edit page which allows you to target a node for particular domains. It also plays nicely with views, panels, and other modules that use ctools selections rules.

This solution is different than true multisite, which is a common set of core and contrib files, but different databases for different sites.

3
  • We have successfully used Domain Access for a couple of projects where some or all of the content/users needed sharing between different sites. Commented Jan 12, 2012 at 12:01
  • ok im need to shared modules,themes,users and all of config for example when config module in all site run. In fact, my site is a multilingual site that contains a database for each language I was home when a change is applied at all sites These changes can be a field or install a module
    – user1630
    Commented Jan 12, 2012 at 14:19
  • One aspect of Domain Access and sharing the same everything between multiple sites is you then need other modules to pull the content apart if you want to only show specific things on specific sites. Domain Access and it's accompanying modules accomplish this quite well, domain access tackles the multisite problem from the opposite angle from drupals built in multisite.
    – leexonline
    Commented Mar 27, 2014 at 9:34
2

This is a bit complicated, but you can create a multi-site environment with shared users and multiple databases. I think it gets very complicated if you want to have separate databases with shared users AND nodes. Have a look at this document for more information about the different setups with pros and cons.