This has been a long road but I think I finally may have gotten there.

I'm keeping my running notes on my site ( http://bbtvnetwork.com/content/tech-news-setting-multsite ) but I will snap a copy of them here for now.

Comments are appreciated if you notice I missed something that will bite me later.

My goal is to run a main system portal at www.main.com
then run many sub-sites at site1.main.com, site2.main.com etc

I'm running on Amazon AWS instance which is basically a RHEL distro.

Since it probably isn't of much interest for this conversation I will condense the setup without comments.

sudo yum update  
sudo vi /etc/yum.repos.d/epel.repo  <-- Under the section marked [epel], change enabled=0 to enabled=1. 
sudo yum install httpd 
sudo yum install mysql mysql-server
sudo yum install phpmyadmin
sudo vi /etc/httpd/conf.d/phpMyAdmin.conf <-- dangerous but don't restrict to localhost for now
sudo yum install php php-mysql php-gd php-xml php-mbstring
sudo yum install vsftpd                                          
sudo mkdir /srv/ftp
sudo usermod -d /srv/ftp ftp
sudo vi /etc/vsftpd/vsftpd.conf  <-- secure anonymous
sudo chkconfig --level 2345 mysqld on 
sudo service mysqld start 
sudo chkconfig --level 2345 httpd on 
sudo service httpd start 
sudo chkconfig --level 2345 vsftpd on 
sudo service vsftpd start 
/usr/bin/mysqladmin -u root password 'NewPW'
Virtual Host Stuff http://gotdrupal.com/videos/multisites-vs-multiple-sites
sudo yum install php-pear
sudo pear channel-discover pear.drush.org
sudo pear install drush/drush
sudo pear upgrade --force Console_Getopt
sudo pear upgrade --force pear
sudo pear upgrade-all
cd /var/www
sudo curl -O http://ftp.drupal.org/files/projects/drupal-7.19.tar.gz
sudo tar -zxvf drupal-7.19.tar.gz
sudo rmdir html   ←make sure on this!
sudo cp-R drupal-7.19 html
cd html
Browse to http://your.site.com/phpmyadmin --->  to create user/pw and main site database

Create the main site using the following drush commands noting that we're using a database prefix of 'shared_' since this is the base from which others will share their user data.

sudo drush site-install standard --account-name=[drupal_admin_user] --account-pass=[drupal_admin_pw] --db-url=mysql://[db_admin_user]:[db_admin_pw]@localhost/[db_name] --site-name="Text Site Name" --site-mail="info@domain.com"  --db-prefix=shared_

sudo drush dl libraries awssdk amazons3 videojs entity rules ctools views cck token devel jquery_update custom_formatters pathauto zen admin_menu themekey-7.x-2.x-dev simplehtmldom devel_theme captcha-7.x-1.x-dev recaptcha

sudo chown –R apache:apache sites/default/files

Enable desired modules and set up the main site. Create users and enable roles etc.

After the main site settles down and you want to create the second site...

Setup the second site files as

sudo mkdir sites/site2.main.com
sudo mkdir sites/site2.main.com/files
sudo chown –R apache:apache sites/site2.main.com/files
sudo cp sites/default/default.settings.php sites/site2.main.com/settings.php
sudo chown apache:apache sites/site2.main.com/settings.php

Run the install on the second site by going to http://site2.main.com/install.php and continue as normal *except* at the database page, go to advanced and set a unique prefix for all of these table. Something like 'site2_'

Note that we have not yet set up the user database sharing yet. To redirect the tables, edit the settings.php file in the second directory to be:

/*************
 *
 * Shared user tables:
 *   authmap
 *   users
 *   role
 *   role_permissions
 *   users_roles
 *   sessions
 */
$databases = array (
  'default' =>
  array (
    'default' =>
       array (
         'database' => '[main table name]',
         'username' => '[db_user]',
         'password' => '[db_pw]',
         'host' => 'localhost',
         'port' => '',
         'driver' => 'mysql',
         'prefix' =>
           array (
              'default' => 'site2_',
              'authmap' => 'shared_',
              'users' => 'shared_',
              'role' => 'shared_',
              'role_permissions' => 'shared_',
              'users_roles' => 'shared_',
              'sessions' => 'shared_',
           ),
       ),
  ),
);

Comments

HeneryH’s picture

Hmm, reCaptcha seems to be not working. In single site mode it keeps nearly 100% of bot users out but here I am getting a lot of bot users.

Something about my user tables and reCaptcha is not working.

I'm trying regular captcha now.

BTW, I had both main and site2 modules set the same in the user/captcha settings.

anjjriit’s picture

I still develop a multisite with drupal 7. I need to share all users field, so i put some prefix on my settings.php.

'field_data_field_first_name' => 'shared_', //stored with shared_ prefix 
'field_revision_field_first_name' => 'shared_', //stored with shared_ prefix 
'field_data_field_last_name' => 'shared_', //stored with shared_ prefix 
'field_revision_field_last_name' => 'shared_', //stored with shared_ prefix 
'field_data_field_phone_ext' => 'shared_', //stored with shared_ prefix 
'field_revision_field_phone_ext' => 'shared_', //stored with shared_ prefix 
'field_data_field_business_unit‎' => 'shared_', // -----> PROBLEM did not stored with shared_ prefix 
'field_revision_field_business_unit‎' => 'shared_', // -----> PROBLEM did not stored with shared_ prefix 
'field_data_field_departement‎' => 'shared_', // -----> PROBLEM did not stored with shared_ prefix 
'field_revision_field_departement‎' => 'shared_', //-----> PROBLEM did not stored with shared_ prefix 

Why my business unit and departement field did not stored with shared_ prefix ?

ramdhanh’s picture

When you created the table? Before or after you amend the settings?

anjjriit’s picture

Actually i have forgot about the time to create that field,
is there a problem about different time of before and after ?
The important things to informed is that field type are Entity reference field from taxonomy term

ramdhanh’s picture

Yes there is a different on that. You should create or amend the settings to direct that table into 'shared_' before that table was created by Drupal. If your table was created before the settings, you can just simply rename it in phpmyadmin for example.

anjjriit’s picture

mmmm...
So my settings.php should contained all database names prefixed,
without database connection settings ?

can we do that ?
why it has never crossed my mind :D

roynilanjan’s picture

@jjflynn22: will check and verify

Great it's working... Just one point need to add then it's working good for SSO ...
We need to add or uncomment

$cookie_domain='.domain.com' // please change your domain name
'sessions' => 'site1_',

this above prefix along with cookie-domain leverage drupal to make single sign-on from master=>slave and vise-verse

liquidcms’s picture

Just to be clear, this thread is NOT discussing "shared user tables" it is discussing "shared drupal database with common user tables", correct?

In other words both sites use a common single database. That database has a ton of tables with shared_ as prefix and tons with site2_ as prefix.

Is it possible to do this with the standard "single database per site" and then have site2 share the user tables from the other database?