drupal multisite setup

39
Multisite & Single Sign On by Ipsita Mishra

Upload: ipsitamishra

Post on 17-May-2015

5.730 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Drupal Multisite Setup

Multisite & Single Sign Onby

Ipsita Mishra

Page 2: Drupal Multisite Setup

Ipsita Mishrahttp://drupal.org/user/172344

IRC Nick: ipsita

Currently working for Melity Inc in association with PCI Hyderabad

Who am I?

Page 3: Drupal Multisite Setup

We will walk through

What is Multisite?

How to setup Multisite

Sharing information between Multisite

Page 4: Drupal Multisite Setup

W W W

What is multisite ? Using a single drupal installation(code base) for creating

multiple site.

Why go for it?

What is assumed?

Page 5: Drupal Multisite Setup

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?

Page 6: Drupal Multisite Setup

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.

Page 7: Drupal Multisite Setup

Mutlisite vs. Multiple sites

www.example.com

www.example.com/site1

site2.example.com

Drupal Code

Still we can keep uniqueness of each 

site

www.example.com

www.example.com/site1

www.example.com/site1

Drupal Code

Drupal Code

Drupal Code

Page 8: Drupal Multisite Setup

Mutlisite vs. Multiple sites

Credit : This is a snapshot from the Video on Multisite by Matt Petrowsky 

Page 9: Drupal Multisite Setup

Multisite Structure

Page 10: Drupal Multisite Setup

Multisite Structure

Page 11: Drupal Multisite Setup
Page 12: Drupal Multisite Setup
Page 13: Drupal Multisite Setup
Page 14: Drupal Multisite Setup
Page 15: Drupal Multisite Setup
Page 16: Drupal Multisite Setup

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

Page 17: Drupal Multisite Setup

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

Page 18: Drupal Multisite Setup

A Sample Virtualhost Configuration

Page 19: Drupal Multisite Setup

Drupal lookup for settings.php

Our website: friends.example.com

Drupal will search for configuration files in the followingorder, using the first configuration it finds:

sites/friends.example.comsites/example.comsites/default

Page 20: Drupal Multisite Setup

Drupal lookup for settings.php

Lets take a complex example : www.sub.example.com/site3

Drupal will not read configuration from

sites/subsites/site3

Page 21: Drupal Multisite Setup

Drupal lookup for settings.php

When searching for a site configuration (for examplewww.sub.example.com/site3), Drupal will search for

configuration files in the following order, using thefirst configuration it finds:

sites/www.sub.example.com.site3/settings.php

Page 22: Drupal Multisite Setup

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 thefirst configuration it finds:

sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php

Page 23: Drupal Multisite Setup

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 thefirst configuration it finds:

sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php

Page 24: Drupal Multisite Setup

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 thefirst 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

Page 25: Drupal Multisite Setup

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 thefirst 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

Page 26: Drupal Multisite Setup

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 thefirst 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

Page 27: Drupal Multisite Setup

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 thefirst 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

Page 28: Drupal Multisite Setup

Single Sign On(SSO)

SSO means when you created a user/pass on one site, it will work on the other site(s)

Page 29: Drupal Multisite Setup

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.

Page 30: Drupal Multisite Setup

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.

Page 31: Drupal Multisite Setup

Prepare database and user(for SSO)

# DB name: drupal_db# DB username: duser

# Password: duserp

Page 32: Drupal Multisite Setup

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';

Page 33: Drupal Multisite Setup

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.

Page 34: Drupal Multisite Setup

Modify settings.php : $db_prefix

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

Page 35: Drupal Multisite Setup

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_',);

Page 36: Drupal Multisite Setup

Install drupal

http://news.example.com/install.php

http://sn.example.com/install.php

Page 37: Drupal Multisite Setup

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.

SSO for two websites with 2 database

Page 38: Drupal Multisite Setup

Resources

http://drupal.org/getting-started/6/install/multi-sitehttp://gotdrupal.com/videos/multisites-vs-multiple-siteshttp://groups.drupal.org/multisite

Page 39: Drupal Multisite Setup

Thank you