CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Multisite on separate servers with extensions
Pages: [1]

Author Topic: Multisite on separate servers with extensions  (Read 852 times)

LoganBear

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.67
  • PHP version: 5.3.28
Multisite on separate servers with extensions
January 05, 2015, 08:03:25 am
I'm trying to set up two Civi/Drupal sites sharing the same DB.  I've got everything working except the extension system.  While the directories are defined properly, (ie, /home/site1/public_html/sites/libraries/civicrm/ext and /home/site2/public_html/sites/libraries/civicrm/ext), site2 seems to think that the extensions live on the site1 directory, which site2 does not have access to.  I refresh and clear cache and sometimes the reverse is true - site1 thinks that the extensions live on site2's directory, again inaccessible by site1.  Is there another setting somewhere I didn't set?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Multisite on separate servers with extensions
January 05, 2015, 08:55:31 am

you might want to override the extension dir settings in civicrm.settings.php

http://wiki.civicrm.org/confluence/display/CRMDOC/Override+CiviCRM+Settings

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

LoganBear

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.67
  • PHP version: 5.3.28
Re: Multisite on separate servers with extensions
January 05, 2015, 09:31:15 am
Thank you for the quick response.  I overrode in the settings.php, and that didn't fix the problem.  I'm still getting the following issue from site2:

Quote
Warning Error loading module file (/home/site1/public_html/sites/all/libraries/civicrm/ext/eu.tttp.noverwrite/noverwrite.php). Please restore the file or disable the module.

I scanned the database to find the reference for 'site1' in relation to extensions, and discovered that the cache table has references to the modules' paths with a full path name.  And it's the full path of site1, which I think site2 is finding.  If they had a relative path from the extension directory, it would work for both sites. 

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Multisite on separate servers with extensions
January 05, 2015, 09:45:47 am

try doing a menu rebuild (which clears the cache as a side effect). that might help sort out the DB issues

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

LoganBear

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.67
  • PHP version: 5.3.28
Re: Multisite on separate servers with extensions
January 05, 2015, 10:08:26 am
There's a cache record labelled 'mapper/moduleFiles' which has the full pathnames, even after clearing the cache.  I think that Civi is looking there, which is causing the problems. 

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Multisite on separate servers with extensions
January 05, 2015, 11:36:25 am
Correct - Civi caches the file locations of the extensions.

Given the DB is shared, is it fair to assume that the intention is for the two sites to run the same set of extensions? (The list of activated extensions would be shared via table "civicrm_extension", and some extensions might suffer data-integrity issues if they're inconsistently activated, so this seems likely.) Assuming yes... the quickest thing (that doesn't require any patching) might be move to the extensions to a neutral location. For example:

 * Put the extensions in /srv/extensions.
 * Set permissions so that the extensions can be read by either system.
 * Update the httpd configuration to expose /srv/extensions on both vhosts. (e.g. in Apache "Alias /extensions /srv/extensions")
 * Update the extension base path and extension base URL in both systems. (To make the extension URL appear different in site 1 and site 2, you might need to use civicrm.settings.php to set the extensions_url differently.)
 * Clear cache

If you don't mind patching, one could modify the function CRM_Extension_System::getCache():

https://github.com/civicrm/civicrm-core/blob/master/CRM/Extension/System.php#L209

Specifically, one could make the 'group' change depending on the current site. A simple version might be:

Code: [Select]
## In CRM_Extension_System::getCache()
  'group' => defined("CIVICRM_EXTENSION_CACHE_GROUP") ? CIVICRM_EXTENSION_CACHE_GROUP : 'ext'

## In civicrm.settings.php for site 1
define('CIVICRM_EXTENSION_CACHE_GROUP', 'ext_site1');

## In civicrm.settings.php for site 2
define('CIVICRM_EXTENSION_CACHE_GROUP', 'ext_site2');


(Edited to remove an incomplete/inaccurate parenthetical.)
« Last Edit: January 05, 2015, 11:45:35 am by totten »

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Multisite on separate servers with extensions
January 05, 2015, 12:34:20 pm
A suggested patch: https://github.com/totten/civicrm-core/commit/6cdf1ef

This basically does the same thing as the patch in the previous comment, but "ext_site1" is computed dynamically to ensure a unique value on any given site. I haven't reproduced or tested with your configuration, but it doesn't seem to cause any regressions in a basic configuration.

LoganBear

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.67
  • PHP version: 5.3.28
Re: Multisite on separate servers with extensions
January 06, 2015, 08:19:00 am
totten,

Thanks.  I applied the patch to both sites and it fixes the problem.  Our configuration is that we're a national organization with chapters.  We are willing to offer our chapters support for CiviCRM as long as they share their contacts with national.  The chapters may or may not host their website where the national site is.  Our chapters like their independence.  So, that's why we have separate servers with a shared database.  And I'm really glad that Civi can work in this configuration.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Multisite on separate servers with extensions
January 06, 2015, 10:25:25 am
See also: https://issues.civicrm.org/jira/browse/CRM-15788

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Multisite on separate servers with extensions

This forum was archived on 2017-11-26.