2

I know that it's possible to have CiviCRM shared across multisite Wordpress, and for a single database to operate in a way that keeps different site's data separately.

I'd like to do something superficially simpler, but which I can't find any mention of anywhere.

I'd like two sites in a multisite install to use the same CiviCRM codebase, but completely separate databases. To my mind, I just don't want to the two website's data mixed together, even if they are kept separate from a user perspective.

Could this be as simple as a PHP switch in the config file which says (psuedocode) ...?

 If Website A:
      Use Database A
 Else:
      Use Database B

But I realise that with logs and Smarty cache files it might be more complicated than that ...

1 Answer 1

2

Well, the answer appears to be 'Yes, it is (almost) that simple'.

The one wrinkle is that you first need to trick CiviCRM into thinking it has not already been installed on another Wordpress network site by moving civicrm.settings.php to an out of the way location.

So, do this:

  1. Move your old civicrm.settings.php file somewhere safe.
  2. Create a new empty MySQL database.
  3. Go to the Wordpress site where you intend to create the new CiviCRM instance and activate the CiviCRM plugin.
  4. CiviCRM will go through the process of installing CiviCRM to the blank database.
  5. A new civicrm.settings.php file will have been created probably in a path like: /path/to/wordpress/wp-content/uploads/sites/2/civicrm/civicrm.settings.php
  6. Restore your old civicrm.settings.php to its original location (in my case this was in /path/to/wordpress/wp-content/plugins/civicrm/ because it's an older install).

The 'old' settings file was edited something like this:

<?php

$site = $_SERVER['SERVER_NAME'] == 'newsite.com' ? 'new' : 'default';

if ($site != 'default'):
    include_once('/path/to/wordpress/wp-content/uploads/sites/2/civicrm/civicrm.settings.php');
else:
    /*The contents of the old original settings file goes here.*/
endif;

?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.