Skip to Content

You are here

Sharing content type, content and users on two different drupal 6 sites

Hello,
I would like to share this blog for those drupal developers who are stuck for sharing the content, users and seperate themes and structures.
You can try this on your local machines windows / linux both.We will be using ip based virtual hosts in this tutorial.
Just follow the steps for installing multisite with same database and same codebase with two different domains.
A. Basic domain setup :
open the "hosts"  file
linux - /etc/hosts
windows - c:/windows/system32/drivers/etc/hosts :
Add the hosts as
127.0.0.1 dev.blackberry.loc
192.168.2.15 ( ie. your machine ip ) dev.blueberry.loc
B. Open your apache settings file
In Linux - /etc/apache2/conf/httpd.conf
<VirtualHost *:80>
        DocumentRoot "/var/www/testproject/example"
        ServerName dev.blackberry.loc
        <Directory "/var/www/testproject/example">
                Allow from all
                Options +Includes +Indexes +FollowSymLinks
                AllowOverride all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot "/var/www/testproject/example"
        ServerName dev.blueberry.loc
        <Directory "/var/www/testproject/example">
                Allow from all
                Options +Includes +Indexes +FollowSymLinks
                AllowOverride all
        </Directory>
</VirtualHost>
In Windows - c:/xampp/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
        DocumentRoot "c:/xampp/htdocs/testproject/example"
        ServerName dev.blackberry.loc
        <Directory "c:/xampp/htdocs/testproject/example">
                Allow from all
                Options +Includes +Indexes +FollowSymLinks
                AllowOverride all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot "c:/xampp/htdocs/testproject/example"
        ServerName dev.blueberry.loc
        <Directory "c:/xampp/htdocs/testproject/example">
                Allow from all
                Options +Includes +Indexes +FollowSymLinks
                AllowOverride all
        </Directory>
</VirtualHost>
DO NOT VISIT THE SITE TILL YOU COMPLETE EDITING THE SETTINGS.PHP FILES FOR ALL SITES..
C. Adding seperate settings.php for each site.
By default it will be directory structure as follows :
 sites/default
you have to copy default.settings.php to settings.php
edit the line
$db_url = 'mysql://username:password@localhost/databasename';
add your database credentials.
as you will be using the same cookie domain specify that in variable
$cookie_domain ="dev.blackberry.loc"
once you are done with the same you can copy the default folder as
sites/default to
sites/dev.blackberry.loc
sites/dev.blueberry.loc
modify settings.php file for dev.blueberry.loc spcifying the db_prefix as follows
$db_prefix = array(
'default' =>'',
'blocks'=> 'blueberry_',
'boxes' => 'blueberry_',
'menu_custom' => 'blueberry_',
'menu_links' => 'blueberry_',
'menu_router' => 'blueberry_',
'variable' => 'blueberry_',
'cache' => 'blueberry_'
);

Once you complete editing all settings.php files visit the
dev.blackberry.loc/install.php
this will install the first site dev.blackberry.loc
Now in order to share the contents and other things you need common tables in both sites.
So drop rest of the tables except blocks,boxes,menu_custom,menu_link,menu_router,variable and cache tables.
Once these are dropped try to install the dev.blueberry.loc with
dev.blueberry.loc/install.php
This will install all the tables which are related to blackberry and blueberry. only above specified tables will have
the special prefix of blueberry_ which will distinguish the two domains.
Finish the installation.
Wowww !!! Now you can visit both sites dev.blackberry.loc and dev.blueberry.loc ,both are different domains but when you create content in one site it will be reflected on another site. :).
Common content types, users you can share like this..
Have fun !!!!

Tags: