Yesterday, I installed my first multisite with which I wanted to share users with an existing site. I was going to use the same database for both sites, and have different prefix names for each of the sites' tables. My original site didn't have any table prefix names to start off with.

I ran into several problems while doing this and I thought it might be helpful to other people to outline the steps I used to successfully install the multisite. I was running Drupal 6.17 on a shared server (1and1).

1. I registered a new domain (it could just as easily be a sub-domain) and pointed it to my existing Drupal installation root folder.

2. I created a new folder in the sites directory to exactly match my new domain.

3. I added a prefix, using phpmyadmin, to the tables I needed to share. These were:

Users
Authmap
Role
Sessions

They became 'shared_users', 'shared_authmap', 'shared_role', 'shared_sessions'.

As my tables didn't have a prefix before, I updated the $db_prefix line in my original settings.php from:

$db_prefix = '';

to:

$db_prefix = array(
      'default'   => '',
      'users'     => 'shared_',
      'sessions'  => 'shared_',
      'role'      => 'shared_',
      'authmap'   => 'shared_',
    );

4. Because I was sharing the same database with the existing website I then copied the settings.php file from my existing sites/all folder into my new multisite folder. I updated the new settings.php file to read:

$db_prefix = array(
      'default'   => 'new_',
      'users'     => 'shared_',
      'sessions'  => 'shared_',
      'role'      => 'shared_',
      'authmap'   => 'shared_',
    );

5. When I then navigated to the homepage for my new domain, I was expecting the install script to automatically run, but nothing was happening. I manually ran it by going to my new domain/install.php. I only managed to complete the first three steps before the process wouldn't go on any further, and I had got several error messages.

6. When I navigated back to the homepage I was now getting an error Fatal error: Call to undefined function user_access(). To fix this I had to manually set specific values in the new system table using phpmyadmin. I edited the following rows:

system.module
node.module
user.module
filter.module
block.module

Making sure that their "status" was all 1 (I found the solution here http://drupal.org/node/809092)

7. Now when I navigated to the home page I was getting the default theme but without any content and there was no way for me to log on. To solve this I ran update.php for the new domain. (you will first need to edit the settings.php file to make the $update_free_access value TRUE).

8. Once update.php had run my new multisite was running fine.

Comments

ymazigo’s picture

thank you it work for me

JoeMcGuire’s picture

Thanks that was great. I also wanted to share the users_roles table.

taggartj’s picture

http://drupal.org/node/323644#comment-6810840

but the above looks to be the best idea

Dhaval’s picture

i hve two different url for same project bt i want to assign different user to different url so plz guys help me