Multisite & Single Sign On by Ipsita Mishra
Who am I? Ipsita Mishra http://drupal.org/user/172344 IRC Nick: ipsita Currently working for Melity Inc in association with PCI Hyderabad
We will walk through What is Multisite? How to setup Multisite Sharing information between Multisite
W W W What is multisite? Using a single drupal installation(code base) for creating multiple site. Why go for it? What is assumed?
W W W What is multisite? Using a single drupal installation(code base) for creating multiple site. Why go for it? Shared codebase means all sites are using the same version(latest version, probably). Better server(site) management, less complex version control system, less management for Security Issues. What is assumed?
W W W What is multisite? Using a single drupal installation(code base) for creating multiple site. Why go for it? Shared codebase means all sites are using the same version(latest version, probably). Better site management, less complex version control system, less management for Security Issues. What is assumed? You have basis knowledge of Apache server configurations & default drupal folder structure.
Mutlisite vs. Multiple sites www.example.com www.example.com Drupal Code www.example.com/site1 Drupal Code www.example.com/site1 www.example.com/site1 Drupal Code site2.example.com Still we can keep uniqueness of each site Drupal Code
Mutlisite vs. Multiple sites Credit : This is a snapshot from the Video on Multisite by Matt Petrowsky
Multisite Structure
Multisite Structure
What is Virtual host? The term Virtual Host refers to the practice of maintaining more than one server on one machine, as differentiated by their apparent hostname. - apache.org Virtual hosting is a method for hosting multiple domain names on a computer using a single IP address. This allows one machine to share its resources, such as memory and processor cycles, to use its resources more efficiently. - Wikipedia
localhost /etc/apache2/sites-available/default The `default` file is read when we type http://localhost in our browser vhost (an example file) /etc/apache2/sites-available/news.example.com
A Sample Virtualhost Configuration
Drupal lookup for settings.php Our website: friends.example.com Drupal will search for configuration files in the following order, using the first configuration it finds: sites/friends.example.com sites/example.com sites/default
Drupal lookup for settings.php Lets take a complex example : www.sub.example.com/site3 Drupal will not read configuration from sites/sub sites/site3
Drupal lookup for settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php
Drupal lookup for settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php
Drupal lookup for settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php
Drupal lookup for settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php
Drupal lookup for settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php
Drupal lookup for settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php sites/example.com/settings.php
Drupal lookup for settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php sites/example.com/settings.php sites/default/settings.php
Single Sign On(SSO) SSO means when you created a user/pass on one site, it will work on the other site(s)
Single Sign On(SSO) SSO means when you created a user/pass on one site, it will work on the other site(s) These sites will share session and user-related tables so once users login to one of the sites, they will auto login to the other site without logging in exclusively.
Single Sign On(SSO) SSO means when you created a user/pass on one site, it will work on the other site(s) These sites will share session and user-related tables so once users login to one of the sites, they will auto login to the other site without logging in exclusively. In addition to that, we can share User roles and profiles among the two sites.
Prepare database and user(for SSO) # DB name: drupal_db # DB username: duser # Password: duserp
Modify settings.php Open settings.php in the folder sites/news.example.com/ $db_url = 'mysql://username:password@localhost/databasename'; change it to, $db_url = 'mysql://duser:duserp@localhost/drupal_db';
Modify settings.php : $db_prefix We have a variable called $db_prefix which will do the magic Since we want to share a database among two sites but not completely, we decide which tables to share / not to share.
Modify settings.php : $db_prefix $db_prefix = array( 'default' => 'news_', 'users' => 'shared_', 'sessions' => 'shared_', 'role' => 'shared_', 'authmap' => 'shared_', 'users_roles' => 'shared_', );
Now edit the settings.php file for sites/sn.example.com Use the same database connection information. $db_url = 'mysql://duser:duserp@localhost/drupal_db'; Then, you add an array of prefixes, which will look like: $db_prefix = array( 'default' => 'sn_', 'users' => 'shared_', 'sessions' => 'shared_', 'role' => 'shared_', 'authmap' => 'shared_', 'users_roles' => 'shared_', );
Install drupal http://news.example.com/install.php http://sn.example.com/install.php
SSO for two websites with 2 database An option : Multisite Login Module # Using a multisite installation. # Using a separate database for each site (no table prefixing, though the code could be modified to allow for this). # Share the users table across all sites (If this is not you, what are you hoping that this module will do for you?) # You need to install the Multisite Api module.
Resources http://drupal.org/getting-started/6/install/multi-site http://gotdrupal.com/videos/multisites-vs-multiple-sites http://groups.drupal.org/multisite
Thank you