Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Wordpress Multitenancy

Wordpress Multitenancy

A brief overview of how we used a multi-tenancy technique with Wordpress deployment at FactoryMedia to reduce the disk usage of our deployed network by 10x, allowing us to grow the network without unscalable infrastructure costs.

Luke Williams

June 12, 2013
Tweet

More Decks by Luke Williams

Other Decks in Programming

Transcript

  1. _shared/ wp-admin/ wp-includes/ index.php wp-lo in.php wp-settin s.php wp-comments-post.php …

    site_a/ wp-admin/ wp-includes/ wp-content/ wp-confi .php index.php wp-lo in.php wp-settin s.php wp-comments-post.php …
  2. _shared/ wp-admin/ wp-includes/ index.php wp-lo in.php wp-settin s.php wp-comments-post.php …

    site_a/ wp-admin/ wp-includes/ wp-content/ wp-confi .php index.php wp-lo in.php wp-settin s.php wp-comments-post.php … site_b/ wp-admin/ wp-includes/ wp-content/ wp-confi .php index.php wp-lo in.php wp-settin s.php wp-comments-post.php …
  3. <?php define('DB_NAME', 'foobar_wp'); define('DB_USER', 'username'); define('DB_PASSWORD', 'password'); define('DB_HOST', "lolcathost"); define('DB_CHARSET',

    'utf8'); define('DB_COLLATE', ''); define('WP_CACHE', true); define('WPLANG', 'en'); define('WP_DEBUG', false); define('AUTH_KEY', '9999999'); ... blah blah $table_prefix = 'wp_'; if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); require_once(ABSPATH . 'wp-settings.php');
  4. <?php define('DB_NAME', 'foobar_wp'); define('DB_USER', 'username'); define('DB_PASSWORD', 'password'); define('DB_HOST', "lolcathost"); define('DB_CHARSET',

    'utf8'); define('DB_COLLATE', ''); define('WP_CACHE', true); define('WPLANG', 'en'); define('WP_DEBUG', false); define('AUTH_KEY', '9999999'); ... blah blah $table_prefix = 'wp_'; if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); require_once(ABSPATH . 'wp-settings.php');
  5. <?php define('DB_NAME', 'foobar_wp'); define('DB_USER', 'username'); define('DB_PASSWORD', 'password'); define('DB_HOST', "lolcathost"); define('DB_CHARSET',

    'utf8'); define('DB_COLLATE', ''); define('WP_CACHE', true); define('WPLANG', 'en'); define('WP_DEBUG', false); define('AUTH_KEY', '9999999'); ... blah blah $table_prefix = 'wp_'; if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); require_once(ABSPATH . 'wp-settings.php');
  6. _shared/ wp-admin/ wp-includes/ wp-core-confi .php index.php wp-lo in.php wp-settin s.php

    wp-comments-post.php … site_a/ confi /wp-tenant-confi .php wp-admin/ wp-includes/ wp-content/ wp-confi .php index.php wp-lo in.php wp-settin s.php wp-comments-post.php …
  7. # config/wp-tenant-config.php define('DB_NAME', 'foobar_wp'); define('DB_USER', 'username'); define('DB_PASSWORD', 'password'); define('DB_HOST', "lolcathost");

    define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); define('WP_CACHE', true); define('WPLANG', 'en'); define('WP_DEBUG', false); define('AUTH_KEY', '9999999'); ... blah blah $table_prefix = 'wp_';
  8. # _shared/wp-core-config.php -> site_a/wp-config.php // require tenant file require_once($_SERVER["DOCUMENT_ROOT"] .

    "/config/wp-tenant- config.php"); define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content'); define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp- content'); if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); require_once(ABSPATH . 'wp-settings.php'); ?>
  9. _shared/ wp-admin/ wp-includes/ index.php wp-core-confi .php wp-lo in.php wp-settin s.php

    wp-comments-post.php … site_a/ confi /wp-tenant-confi .php wp-admin/ wp-includes/ wp-content/ wp-confi .php index.php wp-lo in.php wp-settin s.php wp-comments-post.php … site_b/ confi /wp-tenant-confi .php wp-admin/ wp-includes/ wp-content/ wp-confi .php index.php wp-lo in.php wp-settin s.php wp-comments-post.php …