Project

General

Profile

Updated over 4 years ago by Jon Goldberg

CiviCRM multi-site checklist

The first two steps have more detailed docs below.
  • Follow the multi-site docs here.
  • Set up cron and Scheduled Jobs per site for sending mail and incoming activity handling (see here).
  • Install the "multisite" extension. There's an install bug on the one on the directory, use github
  • Multisite extension adds new permissions which need setting. If using Domain Access, you can set the permissions once. If using Wordpress or Drupal "true" multi-site, user permissions are per-site!
    • CiviCRM Multisite: view all contacts in domain
    • CiviCRM Multisite: edit all contacts in domain
    • CiviCRM Multisite: list all groups in domain
  • Make sure you set all the settings that are per-site! Especially:
    • Postal/e-mail address for the default organization
    • "From" Addresses
    • CiviMail > Mail Accounts > Bounce Account (should match main site)
    • CiviMail > Mail Accounts > Email-to-Activity account (unique per site)
    • System Settings > Outbound Email (usually should match main site)
    • If Wordpress: base page (note that this allows you to set a different theme per site)

Editing civicrm.settings.php

Protip: Did you remember to comment out CIVICRM_DOMAIN_ID and CIVICRM_UF_BASEURL?

If you're using a "true" multi-site, where each site has its own civicrm.settings.php, the documentation on the CiviCRM wiki will suffice. Even if you're using Wordpress or Domain Access, there's good documentation there (I know, I wrote most of it).

The trick is to write code that can determine your domain based on the URL. Here is an example of how to do that using Domain Access or Wordpress with subdomain multi-site:

switch ($_SERVER['SERVER_NAME']) {

case 'www.xxx.org':
case 'xxx.org':
  define( 'CIVICRM_DOMAIN_ID', 1 );
  define( 'CIVICRM_DOMAIN_GROUP_ID', 2);
  define( 'CIVICRM_DOMAIN_ORG_ID', 105383);
  define( 'CIVICRM_UF_BASEURL'      , 'http://www.xxx.org/' );
  $civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = 'http://www.xxx.org/sites/all/modules/civicrm';
  break;

case 'cdp.xxx.org' :
  define( 'CIVICRM_DOMAIN_ID', 2 );
  define( 'CIVICRM_DOMAIN_GROUP_ID', 19);
  define( 'CIVICRM_DOMAIN_ORG_ID', 106726);
  define( 'CIVICRM_UF_BASEURL'      , 'http://cdp.xxx.org/' );
  $civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = 'http://cdp.xxx.org/sites/all/modules/civicrm';
  break;
// etc.
}

Wordpress with subfolder multi-site is a little trickier, here's what I've got. Note that this allows you to set a POST variable when running cron (via wget) to specify the correct site:

$multi_site_path = explode("/", $_SERVER[REQUEST_URI]);
if ($multi_site_path[6] == "cron.php") {
    $multi_site_choice = $_POST["site"];
} else {
    $multi_site_choice = $multi_site_path[1];
}

switch ($multi_site_choice) {

case 'wp-admin':
case '':
case false:
  define( 'CIVICRM_DOMAIN_ID', 1 );
  define( 'CIVICRM_DOMAIN_GROUP_ID', 84);
  define( 'CIVICRM_DOMAIN_ORG_ID', 1);
  define( 'CIVICRM_UF_BASEURL'      , 'http://www.yyy.org/' );
  break;

case 'hcnmd':
  define( 'CIVICRM_DOMAIN_ID', 2 );
  define( 'CIVICRM_DOMAIN_GROUP_ID', 74);
  define( 'CIVICRM_DOMAIN_ORG_ID', 67459);
  define( 'CIVICRM_UF_BASEURL'      , 'http://www.yyy.org/hcnmd' );
  break;
// etc.
}

Cron with multiple sites

You need to run cron separately for each site to run its scheduled jobs. Here's a good example of how to set it up.

0,15,30,45 * * * * /usr/bin/wget --config=/home/members/xxx/sites/xxx.org/users/xxx/xxx.org/include/civicrm-wgetrc http://www.xxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php
1,16,31,46 * * * * /usr/bin/wget --config=/home/members/xxx/sites/xxx.org/users/xxx/xxx.org/include/civicrm-wgetrc-site2 http://www.xxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php
2,17,32,47 * * * * /usr/bin/wget --config=/home/members/xxx/sites/xxx.org/users/xxx/xxx.org/include/civicrm-wgetrc-site3 http://www.xxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php
3,18,33,48 * * * * /usr/bin/wget --config=/home/members/xxx/sites/xxx.org/users/xxx/xxx.org/include/civicrm-wgetrc-site4 http://www.xxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php
4,19,34,49 * * * * /usr/bin/wget --config=/home/members/xxx/sites/xxx.org/users/xxx/xxx.org/include/civicrm-wgetrc-site5 http://www.xxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php
5,20,35,50 * * * * /usr/bin/wget --config=/home/members/xxx/sites/xxx.org/users/xxx/xxx.org/include/civicrm-wgetrc-site6 http://www.xxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php

Note that each civicrm-wgetrc file has the "site" set differently in the post-data. E.g.:

post-data=name=civicron&pass=<redacted>&key=<redacted>&site=site5
output_document = -
quiet=on
timeout=1

Also available in: PDF HTML TXT

Go to top
Add picture from clipboard (Maximum size: 40 MB)