Configuring multiple CiviCRM on single Drupal

Update: Note that these instructions won’t work for Drupal 7 (due to some changes in core), hence this post is obsolete. Hence I would recommend single code base and separate drupal db for each multi-site. For eg: for CiviCRM 4.3 site you will need 2 db’s drupal_43 and civicrm_43 for drupal and civicrm respectively. ( 1 Feb 2013 )

This instructions were originally written for Ubuntu, but can be used for other operating systems.

We will setup http://civicrm , which will be on CiviCRM trunk and http://civicrm21, which will be on CiviCRM v2.1 branch.

1. Download Drupal from drupal.org. Untar and copy it to /var/www/drupal-6.6.
2. We need multi-site Drupal setup. So create “civicrm” folder in sites/ .
3. Now we need to define Virtualhost in apache. You can read instructions from: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
OR you can follow my instructions:

i) In your /etc/apache2/site-available. Create new file civicrm and copy below code
<VirtualHost *:80>
ServerName civicrm

DocumentRoot /var/www/drupal-6.6
<Directory /var/www/drupal-6.6/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog /var/log/apache2/civicrm_error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/civicrm_access.log combined

</VirtualHost>

ii) sudo a2ensite civicrm
iii) sudo /etc/init.d/apache2 restart

This will create apache virtual host.

Then modify your /etc/hosts and to add new site “civicrm”

127.0.1.1    civicrm

Restart your network: sudo /etc/init.d/networking restart

4. Now you new site is ready and you can install drupal using http://civicrm

While installing you might get errors like;

“Copy the ./sites/civicrm/default.settings.php file to ./sites/civicrm/settings.php”

So copy sites/defaults/default.setting.php to sites/civicrm/settings.php

If you want clean url’s edit your .htaccess accordingly.

Important Note:

For your second site ie. http://civicrm21 you need to follow few more steps:
– take a drupal database table “system” dump (structure and data)
– create another new table for 21_system with above above dump
– add db prefix in your settings.php
$db_prefix = array( ‘system’ => ’21_’);
– specify $cookie_domain in your settings.php ( for eg civicrm21 )

5. After that install CiviCRM, you can get it from http://civicrm.org

Untar and copy civicrm folder in “sites/civicrm/modules/”.

Just in case you are running civicrm from svn. Then your settings_location.php should be like:

define( ‘CIVICRM_CONFDIR’, ‘/var/www/drupal-6.6/sites/civicrm’ );

For installing another instance of civicrm you need to create another site in drupal. So sites/civicrm21. Then repeat above steps.

So http://civicrm (CiviCRM trunk) and http://civicrm21 (CiviCRM v2.1)

Enjoy CiviCRM and Drupal 🙂

3 thoughts on “Configuring multiple CiviCRM on single Drupal”
  1. Hi,

    I remember there is a magic variable to set so the civicrm can be in a different place (say /usr/src/civicrm.trunk) and symlink it in /var/www/drupal/sites/all/modules

    Dare detailing how to do that config ?

    Moreover, I haven’t be successful with crons, and rest apis, is there a way to make it work ?

    X+

  2. My multi-site structure :

    v2.1: sites/civicrm21/modules/civicrm
    v2.2: sites/civicrm22/modules/civicrm
    trunk: sites/civicrm/modules/civicrm

    As confirmed with drupal guys you cannot have same module, but multiple paths in system table.
    So I created 22_system table with dump from system table and added $db_prefix = array( ‘system’ => ’22_’) in my sites/civicrm22/settings.php, which mean I have separate system table for each multi-site.

    May be not recommended approach but worked for me

    Also check forum thread: http://forum.civicrm.org/index.php/topic,6458.0.html

    Kurund

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.