CiviCRM multi-site checklist » History » Version 2
Jon Goldberg, 03/06/2015 02:38 PM
1 | 1 | Jon Goldberg | {{lastupdated_at}} by {{lastupdated_by}} |
---|---|---|---|
2 | |||
3 | h1. CiviCRM multi-site checklist |
||
4 | |||
5 | The first two steps have more detailed docs below. |
||
6 | 2 | Jon Goldberg | * Follow the multi-site docs "here":http://wiki.civicrm.org/confluence/display/CRMDOC/Multi+Site+Installation. |
7 | 1 | Jon Goldberg | * Set up cron jobs per site for sending mail and incoming activity handling (see "here":http://wiki.civicrm.org/confluence/display/CRMDOC/CiviMail+in+a+multisite). |
8 | 2 | Jon Goldberg | * Install the "multisite" extension. There's an install bug on the one on the directory, use "github":https://github.com./eileenmcnaughton/org.civicrm.multisite |
9 | 1 | Jon Goldberg | * 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! |
10 | ** CiviCRM Multisite: view all contacts in domain |
||
11 | ** CiviCRM Multisite: edit all contacts in domain |
||
12 | ** CiviCRM Multisite: list all groups in domain |
||
13 | * Make sure you set all the settings that are per-site! Especially: |
||
14 | ** Postal/e-mail address for the default organization |
||
15 | ** "From" Addresses |
||
16 | ** CiviMail > Mail Accounts > Bounce Account (should match main site) |
||
17 | ** CiviMail > Mail Accounts > Email-to-Activity account (unique per site) |
||
18 | ** If Wordpress: base page (note that this allows you to set a different theme per site) |
||
19 | |||
20 | |||
21 | h3. Editing civicrm.settings.php |
||
22 | |||
23 | *Protip: Did you remember to comment out CIVICRM_DOMAIN_ID and CIVICRM_UF_BASEURL?* |
||
24 | |||
25 | 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). |
||
26 | |||
27 | 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: |
||
28 | <pre> |
||
29 | switch ($_SERVER['SERVER_NAME']) { |
||
30 | |||
31 | case 'www.xxx.org': |
||
32 | case 'xxx.org': |
||
33 | define( 'CIVICRM_DOMAIN_ID', 1 ); |
||
34 | define( 'CIVICRM_DOMAIN_GROUP_ID', 2); |
||
35 | define( 'CIVICRM_DOMAIN_ORG_ID', 105383); |
||
36 | define( 'CIVICRM_UF_BASEURL' , 'http://www.xxx.org/' ); |
||
37 | $civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = 'http://www.xxx.org/sites/all/modules/civicrm'; |
||
38 | break; |
||
39 | |||
40 | case 'cdp.xxx.org' : |
||
41 | define( 'CIVICRM_DOMAIN_ID', 2 ); |
||
42 | define( 'CIVICRM_DOMAIN_GROUP_ID', 19); |
||
43 | define( 'CIVICRM_DOMAIN_ORG_ID', 106726); |
||
44 | define( 'CIVICRM_UF_BASEURL' , 'http://cdp.xxx.org/' ); |
||
45 | $civicrm_setting['URL Preferences']['userFrameworkResourceURL'] = 'http://cdp.xxx.org/sites/all/modules/civicrm'; |
||
46 | break; |
||
47 | // etc. |
||
48 | } |
||
49 | </pre> |
||
50 | |||
51 | 2 | Jon Goldberg | 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: |
52 | 1 | Jon Goldberg | <pre> |
53 | $multi_site_path = explode("/", $_SERVER[REQUEST_URI]); |
||
54 | if ($multi_site_path[6] == "cron.php") { |
||
55 | $multi_site_choice = $_POST["site"]; |
||
56 | } else { |
||
57 | $multi_site_choice = $multi_site_path[1]; |
||
58 | } |
||
59 | |||
60 | |||
61 | switch ($multi_site_choice) { |
||
62 | |||
63 | case 'wp-admin': |
||
64 | case '': |
||
65 | case false: |
||
66 | define( 'CIVICRM_DOMAIN_ID', 1 ); |
||
67 | define( 'CIVICRM_DOMAIN_GROUP_ID', 84); |
||
68 | define( 'CIVICRM_DOMAIN_ORG_ID', 1); |
||
69 | define( 'CIVICRM_UF_BASEURL' , 'http://www.yyy.org/' ); |
||
70 | break; |
||
71 | |||
72 | case 'hcnmd': |
||
73 | define( 'CIVICRM_DOMAIN_ID', 2 ); |
||
74 | define( 'CIVICRM_DOMAIN_GROUP_ID', 74); |
||
75 | define( 'CIVICRM_DOMAIN_ORG_ID', 67459); |
||
76 | define( 'CIVICRM_UF_BASEURL' , 'http://www.yyy.org/hcnmd' ); |
||
77 | break; |
||
78 | 2 | Jon Goldberg | // etc. |
79 | } |
||
80 | </pre> |
||
81 | |||
82 | h3. Cron with multiple sites |
||
83 | |||
84 | 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. |
||
85 | |||
86 | <pre> |
||
87 | 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 |
||
88 | 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 |
||
89 | 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 |
||
90 | 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 |
||
91 | 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 |
||
92 | 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 |
||
93 | </pre> |
||
94 | |||
95 | Note that each @civicrm-wgetrc@ file has the "site" set differently in the post-data. E.g.: |
||
96 | <pre> |
||
97 | post-data=name=civicron&pass=<redacted>&key=<redacted>&site=site5 |
||
98 | output_document = - |
||
99 | quiet=on |
||
100 | timeout=1 |
||
101 | 1 | Jon Goldberg | </pre> |