I'm trying to setup a Multisite using a single database and some shared tables with MySQL 5.

After reading a lot of documentation I've decided to try this for the first time and use the New Drupal 6.0 Release.

What I can't seem to figure out is how to create the tables properly.

I need to have more details on the process on creating multisites.
All the documentation on the website are skipping some parts which is
where I run into problems.

Under the "sites" directory I created 2 additional directories so I have:

(All)
Default
www.xxx2.com
www.xxx3.com

All 3 sites will have different content but will be using some shared tables for Login...ect.

So when starting from Scratch I've put the default.settings.php file in each of these directories and I've modified the code to:

For the default:

$db_url = 'mysql://xxx:xxx@xxx.xxx.xxx/xxx'; (with the proper database access info of course)
$db_prefix = array(
'default' => 'xx1_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
'sequences' => 'shared_',
);

For the www.xxx2.com

$db_url = 'mysql://xxx:xxx@xxx.xxx.xxx/xxx'; (with the proper database access info of course)
$db_prefix = array(
'default' => 'xx2_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
'sequences' => 'shared_',
);

For the www.xxx3.com

$db_url = 'mysql://xxx:xxx@xxx.xxx.xxx/xxx'; (with the proper database access info of course)
$db_prefix = array(
'default' => 'xx3_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
'sequences' => 'shared_',
);

All domains are pointing to the same directory on the server.

But when I run the Install.php file on the 1st site I always get errors after entering the database info.

Is there another php file I can run besides the Install.php to create the tables???
Because the install.php file just replaces my $db_prefix variable to something else (empty or whatever I've specified in the field)
and than I get an error and it doesn't want to create the tables.

I wanna be able to skip the part where it's asking me the Database Info / Location / Table Prefixes... since I've already hardcoded
them in the default.settings.php file.

Hope someone can explain this part of the process to me.

Thanks

Comments

ninelives’s picture

I am trying to do this same exact thing. And I'm having the same issue. I've been running 5.2 for while now on a test site configuring it to work for my needs.

Now that 6 is out I wanted take my knowledge and experience and try setting it up properly. Unfortunately I can't even get past the first part.

If I find any info I'll post it here.

ninelives’s picture

multisite installation process changes from d5 to d6
http://drupal.org/node/210238

Multisite installation fails with shared tables - "So am I on the right track that a multisite setup with shared tables won't be possible with Drupal 6.0?"
http://drupal.org/node/209862

ninelives’s picture

This Document lead me in a working direction. http://drupal.org/node/201673

I had to make a few changes for 6. First I had to have a blank settings.php file in /sites/default. If the default file had settings it seemed to overpower the sites. Second I used the shared tables idea from the settings files as you are trying to do.

The next step for me is trying to get a shared cookie setup so that I can login on any of the sites and have the session work on all of them.

ninelives’s picture

I guess my knowledge isn't staying with me that well. The shared cookie is simply a line in the settings.php file for each site.

$cookie_domain = 'example.com';

TheGMan’s picture

I still don't get how to create the Tables for the additional sites.

I run the install file for the default site, it creates the tables with my first prefix and I changed some of the tables to shared_...
(by manually going in the database)

than I manually modified the settings.php file in the default directory to look at the shared_... tables for the particular ones that I've changed.

The only way I was able to get to my other sites was to rename the default directory to my default domain name "www.xxx1.com". If not, it would always go to the default site and not to the specified domain.

I've copied a blank default.settings.php file in the other sites directories (because if this file is not there, the install.php doesn't run)
but when I run the install from the 2nd site it's always looking in the sites/default/ directory for the settings.php file...

So I guess there must be another way of creating the tables for other sites.

None of the links you gave me talk about this. I have read the http://drupal.org/node/201673 many times before and they don't talk about how they created the other tables.

I'll keep on looking around... I wish someone would write a step by step document for this. It's all bits and pieces everywhere.

astra’s picture

Try this way.

Because running Drupal 6 install.php can automatically configure the database info within settings.php, so don't change anything to the settings.php before you running install.php. You do:

to copy the default settings.php to folders site/www.xxx2.com and site/www.xxx3.com, Don't chnage anything to each of the three settings.php.;

to run www.xxx1.com/install.php and enter the database info with the table prefix xx1;

to run www.xxx2.com/install.php and enter the same database info with the table prefix xx2;

to run www.xxx3.com/install.php and enter the same database info with the table prefix xx3;

Now there are 3 set of tables with different prefix in your database.

to go to the database to modify tables by PhpMyAdmin:

to change tables

xx1_users
xx1_sessions
xx1_role
xx1_authmap
xx1_sequences

as

shared_users
shared_sessions
shared_role
shared_authmap
shared_sequences

to delete tables below

xx2_users
xx2_sessions
xx2_role
xx2_authmap
xx2_sequences

and

xx3_users
xx3_sessions
xx3_role
xx3_uthmap
xx3_sequences

Now the database is what you need.

Then to go back to set the three settings.php

For the default:

$db_url = 'mysql://xxx:xxx@xxx.xxx.xxx/xxx'; (to be already set as right info by running site1 install.php)
$db_prefix = array(
'default' => 'xx1_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
'sequences' => 'shared_',
);

For the www.xxx2.com

$db_url = 'mysql://xxx:xxx@xxx.xxx.xxx/xxx'; (also to be already set as right info by running site2 install.php)
$db_prefix = array(
'default' => 'xx2_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
'sequences' => 'shared_',
);

For the www.xxx3.com

$db_url = 'mysql://xxx:xxx@xxx.xxx.xxx/xxx'; (also to be already set as right info by running site3 install.php)
$db_prefix = array(
'default' => 'xx3_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
'sequences' => 'shared_',
);

Finally to browse to your main site www.xxx1.com and sign up your first user account. And the other two site should share users.

Good luck!

TheGMan’s picture

Here's what happens:

I did has you instructed:

"copy the default settings.php to folders site/www.xxx2.com and site/www.xxx3.com, Don't chnage anything to each of the three settings.php.;

run www.xxx1.com/install.php and enter the database info with the table prefix xx1;"

Up to there all is good. Drupal creates my first site and populates the database with the first prefix.

My problem has always been, how do I create the tables for the other sites?????

Right now I have my directories setup like this:

sites/default/ (this is where my www.xxx1.com site is)
sites/www.xxx2.com/
sites/www.xxx3.com/

I've tried to rename the default directory to www.xxx1.com but the first install.php would not run.

After running the install.php for www.xxx1.com I tried running the www.xxx2.com/install.php but I get an error right away.

Drupal already installed
To start over, you must empty your existing database.
To install to a different database, edit the appropriate settings.php file in the sites folder.
To upgrade an existing installation, proceed to the update script.
View your existing site.

So the only solution I found is to rename the default directory to www.xxx1.com
this is the only way that drupal doesn't go to the default directory and I'm able to run the install.php on other sites,

but once I enter my database info for the 2nd site I get this error.

Warning: fopen(./sites/default/default.settings.php): failed to open stream

Why is it always trying to open the default directory??? isn't is suppose to check in the current site directory for this file?
And I have no choice of renaming that directory because I cannot get to my other sites if I don't. All my domains point to the
default directory instead of the proper site their are suppose to. Is there any other settings I need to do in the DNS tables?

Right now all I'm doing is pointing my other domains to my www.xxx1.com domain. (which is where my drupal 6 installation resides)

Hope you can help

astra’s picture

After running the install.php for www.xxx1.com I tried running the www.xxx2.com/install.php but I get an error right away.

Drupal already installed

It seems your www.xxx2.com is not a separate site, but just redirect to www.xxx1.com. For multisites configuration each of your other site (www.xxx2.com, www.xxx3.com) must be created a symlink to point the Drupal system (www.xxx1.com). Are you sure you create right symbolic links for them?

gflare’s picture

I had the same problem.

Once you setup one site. rename the settings.php file for that site, then logon to the other domain or subdomain and install again. repeat the process as much as needed, then rename all the settings.php back to the correct format and you will then have different drupal sites based on your entry point (domain / subdomain)

I'm in a bit of a hurry, but i'll try to check back later and clarify if needed.

dharmendra’s picture

While installing the ‘Profile Module’, how to close old database connection and create a new connection with new database
i want to make a different new database with profile table for save profile information.
how to implement this with user-profile module at the time of multiple sites implementation.

In shortly i want to use a different database for all multiple sites in same domain which are developed by drupal -5.0

dharmendra’s picture

how can we integrates a php page with multiple sites?

How can apply session in a php page for integrating with multiple sites of drupl

TheGMan’s picture

I need someone to explain or give me the proper Symlinks I should create.

I've read many forums about these but still don't get how it works with Drupal...or what's the difference
with Forwarding directly the domain to the main drupal installation directory or creating a Symlink

Right now, GoDaddy is pointing my www.xxx1.com domain to a directory on my hosting service called xxx1
(so something like /home/u/s/r/username/html/xxx1/ in unix)

I've installed Drupal 6 in the root of that directory.

I've created 2 additional directories under the /sites/ drupal directory so i have:

sites/default (for my www.xxx1.com)
sites/www.xxx2.com
sites/www.xxx3.com

I've also copied blank default.settings.php files in these directories. (and gave these files and directories full rights)

What I've been doing so far is relied on GoDaddy pointers. All I did was setup my www.xxx2.com and www.xxx3.com domain
to point to the same directory as my www.xxx1.com.

If i am reading all these posts correctly I guess I should've done some SYMLINKs instead. (I don't really understand the difference).

But anyhow. now that I know how to create symlinks through PHP scripts,
can anyone give my the SYMLINKS I should create according to my specific setup?

*Before creating the SYMLINKS should I remove my www.xxx2.com and www.xxx3.com GoDaddy pointers?????

Thanks in advance.

astra’s picture

A lot of discuss about symlinks on this post: http://drupal.org/node/107347

TheGMan’s picture

I made some symlinks the way everyone does them and I see them on my server
but I have NO IDEA where to point my domains to (the ones I created the symlinks for).

I thought I would point them to the directory where my symlinks are (where my drupal installation is)
but this doesn't change anything.

Once I create the first site with the table (default, main install) if I try and access my other domains they just launch the default site (which I've just installed)... really trying to get this working...do I also have to create a symlink for my main/default domain?

P.S. I've also tried to create symlinks to another directory not where my drupal is install and it still launches my default site...

I thought that creating the /sites/ directories would tell Drupal to look in these for the settings.php file (for the specific domain I'm coming from) but doesn't seem like that's what it's for...and if it is than it just doesn't work with Drupal 6. (or I just haven't found the proper way of setting this up)...

current settting:

/home/usernamexxx/htmlxxx/xxx1/ (this is where Drupal is installed)
/home/usernamexxx/htmlxxx/xxx2/ (this is a symlink to xx1)

under the xxx1 directory I have installed Drupal and created a directory under /sites/ called www.xxx2.com
and copied the default.settings.php empty file.

but there is something wrong I'm doing here...unless I need to name the directory under /site/ with the same name that
I gave my Symlink? I'll try that... but i don't have much hope.

TheGMan’s picture

You know the more I'm trying stuff the more I think this is not me doing something wrong but Drupal 6 acting up...

I mean after isntalling the first site (default) if I rename taht directory to /sites/www.xxx1.com/ instead of /sites/default/
I am able to access my www.xx2.com install.php just by typing www.xxx2.com in the browser (like it's suppose to)

But when it goes to create the tables (after I enter the databse info) I get a crap load of errors because it's trying to open a file under the DEFAULT directory which I have renamed...

Warning: fopen(./sites/default/default.settings.php): failed to open stream

Shouldn't Drupal open/read/write the file(s) under the /sites/www.xx2.com/ directory??? I think this "default" directory has been hardcoded somewhere in the install process and it shouldn't...can anyone confirm??? Something has not been coded right for multisites using full domain names thats for sure...

astra’s picture

Once I create the first site with the table (default, main install) if I try and access my other domains they just launch the default site (which I've just installed)...

It seems your other domains have not the symlinks to the first site where Drupal is installed. The second site with a right symlink should start to run install.php rather than launch the default site.

Are you sure that your /home/usernamexxx/htmlxxx/xxx2/ has a right symlink to your xxx1? How did you check that's correct? Trying to go to your web management panel, and browse to this folder /home/usernamexxx/htmlxxx/xxx2/, and see what happen?

TheGMan’s picture

When I surf to the ../html/xx2/ directory I see the content of my ../html/xxx1/ directory (just like it's suppose to).

But it's still launches the Default site. So i know the problem is not with the links... I'm really running out of options...

astra’s picture

You said you have directories setup like this:

sites/default/ (this is where my www.xxx1.com site is)
sites/www.xxx2.com/
sites/www.xxx3.com/

Try this settings:

sites/default (this is where my www.xxx1.com site is)
sites/www.xxx1.com.xxx2
sites/www.xxx1.com.xxx3

See what happen.

TheGMan’s picture

tried it.... I still get "Drupal is already installed" when I got to

http://www.xxx2.com/install.php

or

http://www.xxx3.com/install.php

Is there anywhere else that I need to specify that I'm doing Multisite...some Config file???

Seems like the Symlinks are reacting the same way as regular domain pointers.

do I have to name my symlinks www.xxx2.com and www.xxx3.com or is just xxx2 and xxx3 fine?

so after I would rename the

/sites/www.xxx1.com.www.xxx2.com
/sites/www.xxx1.com.www.xxx3.com

??? (I don't see how this would be different from your previous exemple)

How come if I rename the /sites/default/ directory to /sites/www.xxx1.com/ than I'm able to get to my other sites?

And why does the Install.php script tries to read or create the config file under /sites/default/ instead of
under /sites/www.xxx1.com.xxx2/ ??? (if i go to www.xxx2.com/install.php)

It all seems to me like I'm missing some line in a config to tell the system not to look at the default site
if I have multisite setup... but I've never seen any instructions talk about this...

TheGMan’s picture

Finally GOT IT!!!

For some reason I restarted everything from Scratch and it worked.

I made my first site and than I copied a default settings.php file under my xxx2 and xxx3 sites/directories
and modified the settings.php with the Database info, Prefix I wanted and shared tables and it works.

Thanks to you all.

TheGMan’s picture

Now I just need to make "Single Login" work...tried to share the Tables and the Cookie but it doesn't work...

astra’s picture

For multi-site single login, to edit the variable '$cookie_domain' near the end of each of your settings.php, it looks like this:
$cookie_domain = 'example.com';

TheGMan’s picture

Thanks for the tip but this is what I have done and it doesn't work.

Actually I've shared the Tables as instructed for Single Login but if
I try to login using my main account on another Site it doesn't login.

So Setting up the "keep the session open" will come after I figure out how to use the same username/password for all my sites.

Can I have one Administrator account for All my Sites??? Because that's the account I've been trying to log-in with.

Also can I administer the accounts from any of the sites or do I have to be on
the main site?

Do you know if there is a Module for Single Sign-on for Drupal 6?

Thanks

astra’s picture

Can I have one Administrator account for All my Sites???

Yes, you can share one admin on each of your multisites.

Also can I administer the accounts from any of the sites or do I have to be on
the main site?

Yes, you can administer all user accouts at any of your multi-site.

There is a Single Sign-on module, but for Drupal 5: http://drupal.org/project/singlesignon

TheGMan’s picture

Yeah I've seen the Module...but I need one for Drupal 6...

I guess I may revert back using Drupal 5 for all my sites... 6 doesn't seem to have much support yet and modules...

Too bad no one has instructions on how to do Single Sign-on with Drupal 6. They have the theory but it doesn't work.

P.S. Also, I've tried to look on my machine for a Drupal Cookie but I found nothing (even after I logged in)...is this normal?