Rogelio's picture

Hi, i installed Backdrop as Multisite following the "Readme" file, the folders are:

public_html/sites/

       web1
         settings.php
       web2
         settings.php

       sites.php

and the sites.php file is

$sites['web1.web.com'] = 'web1';
$sites['web2.web.com'] = 'web2';

The sites have separate databases and work as expected with only one installation, but how to configure the settings.php to share content and users? i cant find information about this

thanks

Accepted answer

I believe $db_prefix setting was replaced by variable $database_prefix  in Backdrop's settings.php. 

If you want to share the entire database, you'll basically end up with the same site with two different URLs. Sharing all tables in the entire database is not hard to do - you just need to indicate that in sites.php. For example, if settings.php for your main site with URL https://example.com is located in folder sites/example, and you want https://another.com to use the same tables in the same database  (that is, use the same settings.php), then sites.php should be configured as follows:

$sites['example.com'] = 'example';
$sites['another.com'] = 'example';

This tells Backdrop to use the settings.php file inside folder sites/example for both URLs.

For more sophisticated sharing, there is the Domain module in D7, which has not been ported to Backdrop (there's a request for porting, but it's a large module). 

I believe you may have been looking at this page. You may want to experiment adapting that with $database_prefix - I really don't know if it will work or not. Keep in mind that some D7 tables don't exist in Backdrop anymore, they've been moved to json files. 

Comments

Do you want to share ONLY content and users? Or the full databases? Sharing only some tables can get really tricky... there are tutorials online on how to do that for D7.

Rogelio's picture

@argiepiano, Either way works for me, but i found this fragment in D7 for settings.php to share tables

$db_prefix = array(
'default' => '',
'blocks' => 'main_',
'boxes' => 'main_',
'menu' => 'main_',
'variable' => 'main_',
'cache' => 'main_',
'cache_menu'=> 'main_',
);

i couldn't get it to work, then it would be better to share the entire database to avoid this

I believe $db_prefix setting was replaced by variable $database_prefix  in Backdrop's settings.php. 

If you want to share the entire database, you'll basically end up with the same site with two different URLs. Sharing all tables in the entire database is not hard to do - you just need to indicate that in sites.php. For example, if settings.php for your main site with URL https://example.com is located in folder sites/example, and you want https://another.com to use the same tables in the same database  (that is, use the same settings.php), then sites.php should be configured as follows:

$sites['example.com'] = 'example';
$sites['another.com'] = 'example';

This tells Backdrop to use the settings.php file inside folder sites/example for both URLs.

For more sophisticated sharing, there is the Domain module in D7, which has not been ported to Backdrop (there's a request for porting, but it's a large module). 

I believe you may have been looking at this page. You may want to experiment adapting that with $database_prefix - I really don't know if it will work or not. Keep in mind that some D7 tables don't exist in Backdrop anymore, they've been moved to json files.