SlideShare une entreprise Scribd logo
1  sur  101
Télécharger pour lire hors ligne
Demystifying
Multisite Architecture
    John VanDyk and James Walker
   Do It With Drupal, December 2008




                                      1
What is Multisite?



                               How Multisite Works



                    Sharing Information Between Sites




                                                                  2

three sections to this presentation, lots of time for questions
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
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.
Why?



       5
6
• Only one copy of the codebase




                                  6
• Only one copy of the codebase
• Only one codebase to upgrade




                                  6
• Only one copy of the codebase
• Only one codebase to upgrade
• Only one set of files to debug



                                  6
• Only one copy of the codebase
• Only one codebase to upgrade
• Only one set of files to debug
• Still have flexibility for site-specific modules


                                                   6
7

Drupal has three essential components.
The filesystem contains the files that make up the Drupal codebase.
$db_url = 'mysqli://joe:secret@localhost/example';




                                                                            8

The database contains content and most configuration settings.
example




                       $db_url = 'mysqli://joe:secret@localhost/example';




                                                                            8

The database contains content and most configuration settings.
example




                       $db_url = 'mysqli://joe:secret@localhost/example';




                                                                            8

The database contains content and most configuration settings.
9

The files directory contains uploaded files.
10

If using private files, the files directory can be outside of the web root.
<?php
require_once './includes/bootstrap.inc';
drupal_bootstrap(FULL);




                                           11
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
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.
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.
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.
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.
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.
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.
http://www.example.com

                                        http://banana.example.com




                                                                    15

We’re talking about having multiple sites on ONE copy of Drupal.
$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.
$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.
$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.
$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.
$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.
Edge case
                 http://www.example.com/something




                                                    17

Need a symlink
http://banana.example.com/fanclub




                                    18
CCK and Views
available for all sites
 porcupine theme
available for all sites




                          19
20
fivestar module
     only available
on banana.example.com




                        20
fivestar module
     only available
on banana.example.com

  bananator module
     only available
on banana.example.com




                        20
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
21

Each site has its own place to put uploaded files.
http://www.example.com/sites/www.example.com/files/
                         image.jpg




                                                         22

mod_rewrite can help make your URLs more friendly
http://www.example.com/sites/www.example.com/files/
                         image.jpg


RewriteRule ^files/(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]




                                                         22

mod_rewrite can help make your URLs more friendly
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
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
Cron!



        24
Updating Multisite



                     25
Updating a Drupal Site




                                                                example




                                                                          26

The database contains content and most configuration settings.
Updating a Drupal Site




                                                                example




                                                                          26

The database contains content and most configuration settings.
Updating a Drupal Site




                                                                example




                                                                          26

The database contains content and most configuration settings.
Updating Multisite


                                                   banana




                                                   cherry




                                                            27

Running update.php once is not enough!
Updating Multisite


                                                   banana




                                                   cherry




                                                            27

Running update.php once is not enough!
Updating Multisite


                                                   banana




                                                   cherry




                                                            27

Running update.php once is not enough!
Updating Multisite


                                                   banana




                                                   cherry




                                                            27

Running update.php once is not enough!
Updating Multisite


                                                   banana




                                                   cherry




                                                            27

Running update.php once is not enough!
Updating Multisite


                                                   banana




                                                   cherry




                                                            27

Running update.php once is not enough!
What is Multisite?



      How Multisite Works



Sharing Information Between Sites




                                    28
Table Prefixing




                                                                 29

Prefixing originally for multiple Drupal sites on cheap hosting
Table Prefixing




                                                                 29

Prefixing originally for multiple Drupal sites on cheap hosting
Table Prefixing




                       $db_prefix = 'zoinks_';


                                                                 29

Prefixing originally for multiple Drupal sites on cheap hosting
$db_prefix = array(
                  'default' => 'main_',
                  'users' => 'shared_',
                  'sessions' => 'shared_',
                  'role'    => 'shared_',
                  'authmap' => 'shared_',
               );




                                             30

settings.php
$db_prefix = array(
                  'default' => '',
                  'users' => 'shared.',
                  'sessions' => 'shared.',
                  'role'    => 'shared.',
                  'authmap' => 'shared.',
               );

                       shared.users
                  databasename.tablename



                                             31

settings.php
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).
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).
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).
access
                               actions       banana
                               actions_aid
                               authmap
                               ...
                               access
                               actions       example
                               actions_aid
                               authmap
                               ...
                                                       33

Still no change in behavior!
users         shared
                               authmap


                               access
                               actions        banana
                               actions_aid
                               authmap
                               ...
                               access
                               actions       example
                               actions_aid
                               authmap
                               ...
                                                       33

Still no change in behavior!
users         shared
                               authmap


                               access
                               actions        banana
                               actions_aid
                               authmap
                               ...
                               access
                               actions       example
                               actions_aid
                               authmap
                               ...
                                                       33

Still no change in behavior!
users         shared
                               authmap


                               access
                               actions        banana
                               actions_aid
                               authmap
                               ...
                               access
                               actions       example
                               actions_aid
                               authmap
                               ...
                                                       33

Still no change in behavior!
“Logged in” means

• Cookie containing session ID
• Entry in sessions table containing session
  ID
• Entry in users table


                                               34
users      shared
        authmap
$user


        sessions   banana
        role




                            35
users      shared
        authmap
$user

        sessions   banana
        role



        sessions   example
        role


                             36
Share user, authmap
Separate login on each site
Simultaneous logins!
User record shared
Roles are not shared
Role assignments are not shared




                                  37
Share user, authmap
Separate login on each site
Simultaneous logins!
User record shared
Roles are not shared
Role assignments are not shared




                                  37
Shared Logins



                38
users
        authmap    shared
        sessions
$user


        role       banana




                            39
users
                             authmap    shared
                             sessions
$user


$db_prefix = array(          role       banana
  'default' => '',
  'users' => 'shared.',
  'authmap' => 'shared.',
  'sessions' => 'shared.',
);




                                                 39
What happens?




                40
What happens?

• Log into http://banana.example.com




                                       40
What happens?

• Log into http://banana.example.com
• Go to http://www.example.com



                                       40
What happens?

• Log into http://banana.example.com
• Go to http://www.example.com
• We’re not logged in!


                                       40
What happens?

• Log into http://banana.example.com
• Go to http://www.example.com
• We’re not logged in!
• Huh?

                                       40
What’s wrong with this picture?


 SESS0787a3dbcceb3bde85599fd17a876fa8de:
     d977085b070ee1f8def0fa7c2fb26ada

SESS2611eb8d937302f9383947cd79a86d6888:
   26bd9e318d607b0581696431bcfb93b1




                                           41
$cookie_domain = ‘example.com’




                                 42
What happens?




                43
What happens?

• Log into http://banana.example.com




                                       43
What happens?

• Log into http://banana.example.com
• Go to http://www.example.com



                                       43
What happens?

• Log into http://banana.example.com
• Go to http://www.example.com
• We’re already logged in!


                                       43
What happens?

• Log into http://banana.example.com
• Go to http://www.example.com
• We’re already logged in!
• Yay!

                                       43
user, authmap, sessions +
         $cookie_domain

One login for all sites
User record shared
Roles are not shared
Role assignments are not shared




                                  44
users
        authmap    shared
        sessions
        role
$user


                   banana




                            45
users
                             authmap    shared
                             sessions
                             role
$user


$db_prefix = array(                     banana
  'default' => '',
  'users' => 'shared.',
  'authmap' => 'shared.',
  'sessions' => 'shared.',
  'role' => 'shared.',
);




                                                 45
46
user, authmap, sessions, role +
        $cookie_domain

One login for all sites
User record shared
Role names/ids shared
Role assignments are not shared




                                   47
users
        authmap
        sessions      shared
        role
        users_roles
$user


                      banana




                               48
users
                                authmap
                                sessions      shared
                                role
                                users_roles
$user

$db_prefix = array(
  'default' => '',                            banana
  'users' => 'shared.',
  'authmap' => 'shared.',
  'sessions' => 'shared.',
  'role' => 'shared.',
  'users_roles' => 'shared.',
);




                                                       48
user, authmap, sessions, role,
users_roles + $cookie_domain

One login for all sites
User record shared
Role names/ids shared
Role assignments shared




                                  49
User                      Role
                      Login   Role
             record                  assignment

  user


+ sessions              *


  + role

    +
users_role



                                                  50
Caution!




           51
Caution!
• Table contention




                         51
Caution!
• Table contention
• Database updates




                        51
Caution!
• Table contention
• Database updates
• Don’t share role
  assignments and not
  role IDs!




                         51
Caution!
• Table contention
• Database updates
• Don’t share role
  assignments and not
  role IDs!

• Think it out using
  stories!



                          51
What is Multisite?



      How Multisite Works



Sharing Information Between Sites




                                    52

Contenu connexe

Tendances (6)

Using python and docker for data science
Using python and docker for data scienceUsing python and docker for data science
Using python and docker for data science
 
Php talk
Php talkPhp talk
Php talk
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwalten
 
Top 5 Non-Obvious Drupal Modules
Top 5 Non-Obvious Drupal ModulesTop 5 Non-Obvious Drupal Modules
Top 5 Non-Obvious Drupal Modules
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Webinar - Managing Files with Puppet
Webinar - Managing Files with PuppetWebinar - Managing Files with Puppet
Webinar - Managing Files with Puppet
 

En vedette (6)

Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Building Social Networking sites with and around drupal
Building Social Networking sites with and around drupalBuilding Social Networking sites with and around drupal
Building Social Networking sites with and around drupal
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
 
Drupal Architecture and functionality
Drupal Architecture and functionality Drupal Architecture and functionality
Drupal Architecture and functionality
 
Information Architecture for Drupal
Information Architecture for DrupalInformation Architecture for Drupal
Information Architecture for Drupal
 
Drupal 7 performance and optimization
Drupal 7 performance and optimizationDrupal 7 performance and optimization
Drupal 7 performance and optimization
 

Similaire à Multisite Van Dyk Walkah

Drupal Multisite Setup
Drupal Multisite SetupDrupal Multisite Setup
Drupal Multisite Setup
ipsitamishra
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
Priceen
 
Cloud, Cache, and Configs
Cloud, Cache, and ConfigsCloud, Cache, and Configs
Cloud, Cache, and Configs
Scott Taylor
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQL
kangaro10a
 
Drupal multisite
Drupal multisiteDrupal multisite
Drupal multisite
Ly Phuong
 

Similaire à Multisite Van Dyk Walkah (20)

Drupal Multisite Setup
Drupal Multisite SetupDrupal Multisite Setup
Drupal Multisite Setup
 
Local Drupal MultiSite Set-up
Local Drupal MultiSite Set-upLocal Drupal MultiSite Set-up
Local Drupal MultiSite Set-up
 
Drupal Multi-site for Fun and Profit
Drupal Multi-site for Fun and ProfitDrupal Multi-site for Fun and Profit
Drupal Multi-site for Fun and Profit
 
Drupal 8 Render Cache
Drupal 8 Render CacheDrupal 8 Render Cache
Drupal 8 Render Cache
 
Scaling in Mind (Case study of Drupal Core)
Scaling in Mind (Case study of Drupal Core)Scaling in Mind (Case study of Drupal Core)
Scaling in Mind (Case study of Drupal Core)
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
 
CloudInit Introduction
CloudInit IntroductionCloudInit Introduction
CloudInit Introduction
 
Drupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappersDrupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappers
 
Apache ignite - a do-it-all key-value db?
Apache ignite - a do-it-all key-value db?Apache ignite - a do-it-all key-value db?
Apache ignite - a do-it-all key-value db?
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
 
DevOps: Docker Workshop
DevOps: Docker WorkshopDevOps: Docker Workshop
DevOps: Docker Workshop
 
Cloud, Cache, and Configs
Cloud, Cache, and ConfigsCloud, Cache, and Configs
Cloud, Cache, and Configs
 
Drupal Multi-Site Setup
Drupal Multi-Site SetupDrupal Multi-Site Setup
Drupal Multi-Site Setup
 
Intro to Drush
Intro to DrushIntro to Drush
Intro to Drush
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQL
 
Top 5 Hadoop Admin Tasks
Top 5 Hadoop Admin TasksTop 5 Hadoop Admin Tasks
Top 5 Hadoop Admin Tasks
 
Webinar: Top 5 Hadoop Admin Tasks
Webinar: Top 5 Hadoop Admin TasksWebinar: Top 5 Hadoop Admin Tasks
Webinar: Top 5 Hadoop Admin Tasks
 
Get Started With Drupal
Get Started With DrupalGet Started With Drupal
Get Started With Drupal
 
Drupal multisite
Drupal multisiteDrupal multisite
Drupal multisite
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Multisite Van Dyk Walkah

  • 1. Demystifying Multisite Architecture John VanDyk and James Walker Do It With Drupal, December 2008 1
  • 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.
  • 5. Why? 5
  • 6. 6
  • 7. • Only one copy of the codebase 6
  • 8. • Only one copy of the codebase • Only one codebase to upgrade 6
  • 9. • Only one copy of the codebase • Only one codebase to upgrade • Only one set of files to debug 6
  • 10. • Only one copy of the codebase • Only one codebase to upgrade • Only one set of files to debug • Still have flexibility for site-specific modules 6
  • 11. 7 Drupal has three essential components. The filesystem contains the files that make up the Drupal codebase.
  • 12. $db_url = 'mysqli://joe:secret@localhost/example'; 8 The database contains content and most configuration settings.
  • 13. example $db_url = 'mysqli://joe:secret@localhost/example'; 8 The database contains content and most configuration settings.
  • 14. example $db_url = 'mysqli://joe:secret@localhost/example'; 8 The database contains content and most configuration settings.
  • 15. 9 The files directory contains uploaded files.
  • 16. 10 If using private files, the files directory can be outside of the web root.
  • 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
  • 33. CCK and Views available for all sites porcupine theme available for all sites 19
  • 34. 20
  • 35. fivestar module only available on banana.example.com 20
  • 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
  • 38. 21 Each site has its own place to put uploaded files.
  • 39. http://www.example.com/sites/www.example.com/files/ image.jpg 22 mod_rewrite can help make your URLs more friendly
  • 40. http://www.example.com/sites/www.example.com/files/ image.jpg RewriteRule ^files/(.*)$ /sites/%{HTTP_HOST}/files/$1 [L] 22 mod_rewrite can help make your URLs more friendly
  • 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
  • 43. Cron! 24
  • 45. Updating a Drupal Site example 26 The database contains content and most configuration settings.
  • 46. Updating a Drupal Site example 26 The database contains content and most configuration settings.
  • 47. Updating a Drupal Site example 26 The database contains content and most configuration settings.
  • 48. Updating Multisite banana cherry 27 Running update.php once is not enough!
  • 49. Updating Multisite banana cherry 27 Running update.php once is not enough!
  • 50. Updating Multisite banana cherry 27 Running update.php once is not enough!
  • 51. Updating Multisite banana cherry 27 Running update.php once is not enough!
  • 52. Updating Multisite banana cherry 27 Running update.php once is not enough!
  • 53. Updating Multisite banana cherry 27 Running update.php once is not enough!
  • 54. What is Multisite? How Multisite Works Sharing Information Between Sites 28
  • 55. Table Prefixing 29 Prefixing originally for multiple Drupal sites on cheap hosting
  • 56. Table Prefixing 29 Prefixing originally for multiple Drupal sites on cheap hosting
  • 57. Table Prefixing $db_prefix = 'zoinks_'; 29 Prefixing originally for multiple Drupal sites on cheap hosting
  • 58. $db_prefix = array( 'default' => 'main_', 'users' => 'shared_', 'sessions' => 'shared_', 'role' => 'shared_', 'authmap' => 'shared_', ); 30 settings.php
  • 59. $db_prefix = array( 'default' => '', 'users' => 'shared.', 'sessions' => 'shared.', 'role' => 'shared.', 'authmap' => 'shared.', ); shared.users databasename.tablename 31 settings.php
  • 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
  • 73. users authmap shared sessions $user role banana 39
  • 74. users authmap shared sessions $user $db_prefix = array( role banana 'default' => '', 'users' => 'shared.', 'authmap' => 'shared.', 'sessions' => 'shared.', ); 39
  • 76. What happens? • Log into http://banana.example.com 40
  • 77. What happens? • Log into http://banana.example.com • Go to http://www.example.com 40
  • 78. What happens? • Log into http://banana.example.com • Go to http://www.example.com • We’re not logged in! 40
  • 79. What happens? • Log into http://banana.example.com • Go to http://www.example.com • We’re not logged in! • Huh? 40
  • 80. What’s wrong with this picture? SESS0787a3dbcceb3bde85599fd17a876fa8de: d977085b070ee1f8def0fa7c2fb26ada SESS2611eb8d937302f9383947cd79a86d6888: 26bd9e318d607b0581696431bcfb93b1 41
  • 83. What happens? • Log into http://banana.example.com 43
  • 84. What happens? • Log into http://banana.example.com • Go to http://www.example.com 43
  • 85. What happens? • Log into http://banana.example.com • Go to http://www.example.com • We’re already logged in! 43
  • 86. What happens? • Log into http://banana.example.com • Go to http://www.example.com • We’re already logged in! • Yay! 43
  • 87. user, authmap, sessions + $cookie_domain One login for all sites User record shared Roles are not shared Role assignments are not shared 44
  • 88. users authmap shared sessions role $user banana 45
  • 89. users authmap shared sessions role $user $db_prefix = array( banana 'default' => '', 'users' => 'shared.', 'authmap' => 'shared.', 'sessions' => 'shared.', 'role' => 'shared.', ); 45
  • 90. 46
  • 91. user, authmap, sessions, role + $cookie_domain One login for all sites User record shared Role names/ids shared Role assignments are not shared 47
  • 92. users authmap sessions shared role users_roles $user banana 48
  • 93. users authmap sessions shared role users_roles $user $db_prefix = array( 'default' => '', banana 'users' => 'shared.', 'authmap' => 'shared.', 'sessions' => 'shared.', 'role' => 'shared.', 'users_roles' => 'shared.', ); 48
  • 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
  • 96. Caution! 51
  • 98. Caution! • Table contention • Database updates 51
  • 99. Caution! • Table contention • Database updates • Don’t share role assignments and not role IDs! 51
  • 100. Caution! • Table contention • Database updates • Don’t share role assignments and not role IDs! • Think it out using stories! 51
  • 101. What is Multisite? How Multisite Works Sharing Information Between Sites 52