2. What is Multisite?
How Multisite Works
Sharing Information Between Sites
2
three sections to this presentation, lots of time for questions
3. http://www.example.com
http://banana.example.com
http://www.example.com/apple
http://pancakeblog.net
3
You can always have multiple Drupal sites on a server, with multiple copies of Drupal
4. http://www.example.com
http://banana.example.com
http://www.example.com/apple
http://pancakeblog.net
4
We’re talking about having multiple sites on ONE copy of Drupal.
18. CONFIGURATION: initialize configuration.
EARLY PAGE CACHE
DATABASE: initialize database layer.
ACCESS: identify and reject banned hosts.
SESSION: initialize session handling.
LATE PAGE CACHE
LANGUAGE: identify the language
PATH: path handling
FULL: Drupal is fully loaded
12
19. CONFIGURATION: initialize configuration.
EARLY PAGE CACHE
DATABASE: initialize database layer.
ACCESS: identify and reject banned hosts.
SESSION: initialize session handling.
LATE PAGE CACHE
LANGUAGE: identify the language
PATH: path handling
FULL: Drupal is fully loaded
13
Multisite happens here.
20. We’ve got a request for http://www.example.com/
That’s from host www.example.com, path /
Let’s look for a settings file at
14
What normally happens.
21. We’ve got a request for http://www.example.com/
That’s from host www.example.com, path /
Let’s look for a settings file at
sites/www.example.com/settings.php
14
What normally happens.
22. We’ve got a request for http://www.example.com/
That’s from host www.example.com, path /
Let’s look for a settings file at
sites/www.example.com/settings.php
sites/example.com/settings.php
14
What normally happens.
23. We’ve got a request for http://www.example.com/
That’s from host www.example.com, path /
Let’s look for a settings file at
sites/www.example.com/settings.php
sites/example.com/settings.php
sites/com/settings.php
14
What normally happens.
24. We’ve got a request for http://www.example.com/
That’s from host www.example.com, path /
Let’s look for a settings file at
sites/www.example.com/settings.php
sites/example.com/settings.php
sites/com/settings.php
sites/default/settings.php
14
What normally happens.
25. http://www.example.com
http://banana.example.com
15
We’re talking about having multiple sites on ONE copy of Drupal.
26. $db_url = 'mysqli://jdoe:secret@localhost/banana';
$db_url = 'mysqli://moe:shhhh@localhost/www';
16
Now banana.example.com will get a site using the banana database; everything else gets the
www database.
27. $db_url = 'mysqli://jdoe:secret@localhost/banana';
banana
$db_url = 'mysqli://moe:shhhh@localhost/www';
16
Now banana.example.com will get a site using the banana database; everything else gets the
www database.
28. $db_url = 'mysqli://jdoe:secret@localhost/banana';
banana
example
$db_url = 'mysqli://moe:shhhh@localhost/www';
16
Now banana.example.com will get a site using the banana database; everything else gets the
www database.
29. $db_url = 'mysqli://jdoe:secret@localhost/banana';
banana
example
$db_url = 'mysqli://moe:shhhh@localhost/www';
16
Now banana.example.com will get a site using the banana database; everything else gets the
www database.
30. $db_url = 'mysqli://jdoe:secret@localhost/banana';
banana
example
$db_url = 'mysqli://moe:shhhh@localhost/www';
16
Now banana.example.com will get a site using the banana database; everything else gets the
www database.
31. Edge case
http://www.example.com/something
17
Need a symlink
36. fivestar module
only available
on banana.example.com
bananator module
only available
on banana.example.com
20
37. fivestar module
only available
on banana.example.com
bananator module
only available
on banana.example.com
gobananas theme
only available
on banana.example.com
20
41. http://www.example.com/sites/www.example.com/files/
image.jpg
RewriteRule ^files/(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]
http://www.example.com/files/image.jpg
22
mod_rewrite can help make your URLs more friendly
42. Summary So Far
• Single codebase
• Everything in sites/all is shared: modules,
themes
• Site-specific modules and themes go in
sites/sitename/
• Each site has its own file uploads directory
23
60. access
actions example
actions_aid
authmap
...
32
What will happen with this arrangement? Nothing different! The location of the two tables has
just changed (users and authmap tables in the example database are unused).
61. users shared
authmap
access
actions example
actions_aid
authmap
...
32
What will happen with this arrangement? Nothing different! The location of the two tables has
just changed (users and authmap tables in the example database are unused).
62. users shared
authmap
access
actions example
actions_aid
authmap
...
32
What will happen with this arrangement? Nothing different! The location of the two tables has
just changed (users and authmap tables in the example database are unused).
63. access
actions banana
actions_aid
authmap
...
access
actions example
actions_aid
authmap
...
33
Still no change in behavior!
64. users shared
authmap
access
actions banana
actions_aid
authmap
...
access
actions example
actions_aid
authmap
...
33
Still no change in behavior!
65. users shared
authmap
access
actions banana
actions_aid
authmap
...
access
actions example
actions_aid
authmap
...
33
Still no change in behavior!
66. users shared
authmap
access
actions banana
actions_aid
authmap
...
access
actions example
actions_aid
authmap
...
33
Still no change in behavior!
67. “Logged in” means
• Cookie containing session ID
• Entry in sessions table containing session
ID
• Entry in users table
34
68. users shared
authmap
$user
sessions banana
role
35
69. users shared
authmap
$user
sessions banana
role
sessions example
role
36
70. Share user, authmap
Separate login on each site
Simultaneous logins!
User record shared
Roles are not shared
Role assignments are not shared
37
71. Share user, authmap
Separate login on each site
Simultaneous logins!
User record shared
Roles are not shared
Role assignments are not shared
37
94. user, authmap, sessions, role,
users_roles + $cookie_domain
One login for all sites
User record shared
Role names/ids shared
Role assignments shared
49
95. User Role
Login Role
record assignment
user
+ sessions *
+ role
+
users_role
50