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) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Multi-Site Subdirectory Install Issues
Pages: [1]

Author Topic: Multi-Site Subdirectory Install Issues  (Read 2507 times)

spork

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.0.1
  • CMS version: Drupal 7
Multi-Site Subdirectory Install Issues
April 25, 2011, 12:43:53 pm
I am doing a shared-codebase, single-domain, subdirectory-URL multi-site installation of D7 / CiviCRM 4. (To clarify, I use a single D7 / CiviCRM codebase in apache's doc root directory, and use symlinks in the doc root directory to point the subdirectory sites back to Drupal's index.php. In the sites folder I have folders called mydomain.org, mydomain.org.subdir1, mydomain.org.subdir2, etc.)

Unfortunately, it seems CiviCRM is using different logic for finding the base URL of the site than Drupal does... So far I have Drupal successfully installed and working on the root site (mydomain.org) and a sub-directory site (mydomain.org/subdir1). I am able to install CiviCRM 4 properly on the root site, but when I try to install CiviCRM on "mydomain.com/subdir1" by going to "http://mydomain.org/subdir1/sites/all/modules/civicrm/install/index.php" CiviCRM complains that it is already installed with the message:

Quote
Oops! CiviCRM is Already Installed
CiviCRM has already been installed in this Drupal site.

    To start over, you must delete or rename the existing CiviCRM settings file - civicrm.settings.php - from [your Drupal root directory]/sites/mydomain.org.
    To upgrade an existing installation, refer to the online http://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Upgrades.

Thus, it looks like CiviCRM installer is not noticing the "subdir1" part of the root URL. As a workaround, maybe I can get it working by manually creating and editing a civicrm.settings.php for the site, but it seems like this should be a supported configuration without such workarounds... or maybe not?
« Last Edit: April 25, 2011, 12:45:39 pm by spork »

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: Multi-Site Subdirectory Install Issues
April 25, 2011, 01:07:23 pm

since you have a use case and your setup, would be great if you can debug the installer and figure out whats happening and why, and get it work in this scenario.

CiviCRM does work with the below configuration, the installer however needs to be fixed. Would be great if we can get a patch for the installer


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

spork

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.0.1
  • CMS version: Drupal 7
Re: Multi-Site Subdirectory Install Issues
April 25, 2011, 02:20:49 pm
Okay, I'm looking at <CiviCRM codebase>/install/index.php and the areas of focus seem to be around line 128, where the install script checks the installation directory:

if ( $installType == 'drupal' ) {
    global $cmsPath;
   
    //CRM-6840 -don't force to install in sites/all/modules/
    require_once "$crmPath/CRM/Utils/System/Drupal.php";
    $cmsPath = CRM_Utils_System_Drupal::cmsRootPath( );

    $siteDir = getSiteDir( $cmsPath, $_SERVER['SCRIPT_FILENAME'] );
    $alreadyInstalled = file_exists( $cmsPath  . CIVICRM_DIRECTORY_SEPARATOR .
                                     'sites'   . CIVICRM_DIRECTORY_SEPARATOR .
                                     $siteDir  . CIVICRM_DIRECTORY_SEPARATOR .
                                     'civicrm.settings.php' );
} elseif ( $installType == 'standalone' ) {
    $alreadyInstalled = file_exists( $crmPath     . CIVICRM_DIRECTORY_SEPARATOR .
                                     'standalone' . CIVICRM_DIRECTORY_SEPARATOR .
                                     'civicrm.settings.php' );
}


and then line 876 where getSiteDir() is defined. (getSiteDir() is also used on line 302 and in 'install/civicrm.php' on line 82.)

It looks like getSiteDir( $cmsPath, $str ) attempts to re-implement conf_path() in Drupal... why not just call conf_path()? Are we trying to avoid bootstrapping Drupal in the installer for some reason?

spork

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.0.1
  • CMS version: Drupal 7
Re: Multi-Site Subdirectory Install Issues
April 26, 2011, 12:33:49 pm
Okay. I've altered 'install/index.php' and changed getSiteDir() to simply use Drupal's conf_path() which seems to have things working properly...

Code: [Select]
// drupal's conf_path() will return something like 'sites/mydomain.org.subdir1'
// this function should return just 'mydomain.org.subdir1'
// note that DRUPAL_ROOT needs to be defined for conf_path to work
function getSiteDir( $cmsPath, $str ) {
require_once $cmsPath.CIVICRM_DIRECTORY_SEPARATOR.'includes'.CIVICRM_DIRECTORY_SEPARATOR.'bootstrap.inc';
$path = explode(CIVICRM_DIRECTORY_SEPARATOR, conf_path());
return $path[1];
}

The caveat is that it uses a Drupal specific call even though Drupal specific code seems to be handled only conditionally in 'install/index.php'. Perhaps the historical reason for this is the stand alone installer? I'm not sure.

Here's the patch (also attached)...

Code: [Select]
--- C:/xampp/htdocs/sites/all/modules/civicrm/install/index.php Mon Mar 14 12:18:28 2011
+++ C:/xampp/htdocs/sites/all/modules/civicrm/install/index.fixed.php Tue Apr 26 13:39:20 2011
@@ -124,7 +124,8 @@
     //CRM-6840 -don't force to install in sites/all/modules/
     require_once "$crmPath/CRM/Utils/System/Drupal.php";
     $cmsPath = CRM_Utils_System_Drupal::cmsRootPath( );
-
+ define('DRUPAL_ROOT', $cmsPath);
+
     $siteDir = getSiteDir( $cmsPath, $_SERVER['SCRIPT_FILENAME'] );
     $alreadyInstalled = file_exists( $cmsPath  . CIVICRM_DIRECTORY_SEPARATOR .
                                      'sites'   . CIVICRM_DIRECTORY_SEPARATOR .
@@ -158,7 +159,6 @@
         errorDisplayPage( $errorTitle, $errorMsg );
     }
 
-    define('DRUPAL_ROOT', $cmsPath);
     $drupalVersionFile = implode(CIVICRM_DIRECTORY_SEPARATOR, array($cmsPath, 'includes', 'bootstrap.inc'));
 
     if ( file_exists( $drupalVersionFile ) ) {
@@ -873,43 +873,16 @@
     }
 }
 
+// drupal's conf_path() will return something like 'sites/mydomain.org.subdir1'
+// this function should return just 'mydomain.org.subdir1'
+// note that DRUPAL_ROOT needs to be defined for conf_path to work
 function getSiteDir( $cmsPath, $str ) {
-    static $siteDir = '';
-   
-    if ( $siteDir ) {
-        return $siteDir;
-    }
-   
-    $sites   = CIVICRM_DIRECTORY_SEPARATOR . 'sites'   . CIVICRM_DIRECTORY_SEPARATOR;
-    $modules = CIVICRM_DIRECTORY_SEPARATOR . 'modules' . CIVICRM_DIRECTORY_SEPARATOR;
-    preg_match( "/" . preg_quote($sites, CIVICRM_DIRECTORY_SEPARATOR) .
-                "([a-zA-Z0-9_.]+)" .
-                preg_quote($modules, CIVICRM_DIRECTORY_SEPARATOR) . "/",
-                $_SERVER['SCRIPT_FILENAME'], $matches );
-    $siteDir = isset($matches[1]) ? $matches[1] : 'default';
-   
-    if ( strtolower( $siteDir ) == 'all' ) {
-        // For this case - use drupal's way of finding out multi-site directory
-        $uri    = explode(CIVICRM_DIRECTORY_SEPARATOR, $_SERVER['SCRIPT_FILENAME']);
-        $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
-        for ($i = count($uri) - 1; $i > 0; $i--) {
-            for ($j = count($server); $j > 0; $j--) {
-                $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
-                if (file_exists($cmsPath  . CIVICRM_DIRECTORY_SEPARATOR .
-                                'sites'   . CIVICRM_DIRECTORY_SEPARATOR . $dir)) {
-                    $siteDir = $dir;
-                    return $siteDir;
-                }
-            }
-        }
-        $siteDir = 'default';
-    }
-
-    return $siteDir;
+ require_once $cmsPath.CIVICRM_DIRECTORY_SEPARATOR.'includes'.CIVICRM_DIRECTORY_SEPARATOR.'bootstrap.inc';
+ $path = explode(CIVICRM_DIRECTORY_SEPARATOR, conf_path());
+ return $path[1];
 }
 
 function errorDisplayPage( $errorTitle, $errorMsg ) {
     include('error.html');
     exit();
 }
-

« Last Edit: April 26, 2011, 03:36:28 pm by spork »

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: Multi-Site Subdirectory Install Issues
April 26, 2011, 02:33:18 pm

spork:

can you please file an issue: http://issues.civicrm.org/ and attach this patch. We'll take a look and integrate it into a future release

thanx

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

spork

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: 4.0.1
  • CMS version: Drupal 7
Re: Multi-Site Subdirectory Install Issues
April 27, 2011, 11:37:33 am
Okay, reported here: http://issues.civicrm.org/jira/browse/CRM-7980

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Multi-Site Subdirectory Install Issues

This forum was archived on 2017-11-26.