Creating a Drupal Multisite in Pantheon

Drupal Multisite is available for Pantheon websites that are hosted on Performance plans.

Pantheon recommends at least a Performance Small plan for a small number of sites as that provides more power and memory, along with the use of Redis, as these enhancements are highly desired. For a multisite setup containing more than a few sites, a larger plan will be necessary.

If you are using domain-based multisites, you will need to have at least one Pantheon domain for each site in the multisite configuration. Should you exceed the domain limit for your current plan, contact [email protected] to increase the limit for your site without needing to upgrade to a larger plan. However, you will still need to upgrade to a larger plan if your site demands more RAM or workers than your current plan offers.

Instructions

  1. Log into the ITS Web Hosting Services Portal
    Navigate to the ITS Web Hosting Service Portal and log in with your credentials.
  2. Create a Drupal Website
    Follow the usual process for creating a Drupal site. Note that, unlike WordPress Multisite on Pantheon, creating a Drupal Multisite does not require selecting a special site type.
  3. Configure as a Drupal Multisite
    After the site is created, configure it as a Drupal Multisite as you would on any other web hosting provider. This involves creating individual site directories, setting up the settings.php files in site directories, creating sites.php from example.sites.php, and configuring additional domain or subdomain routing if needed.
  • To manage files on Pantheon, create a directory for each site in the /files directory. Then create a symlink to that directory within your sites directory. Most easily managed locally.

    Example:

$ cd web/sites/subdomain.site.umich.edu

$ ln -nsf ../default/files/subdomain.site.umich.edu files

 

  • To configure your database, you should set a prefix for the site and include the Pressflow logic from the Pantheon settings file to load database credentials.
     <?php
    
    $databases['default']['default'] = array (
      'prefix' => 'multi_',
      'host' => 'dbhost',
      'port' => '6033',
      'isolation_level' => 'READ COMMITTED',
      'driver' => 'mysql',
      'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql',
      'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
    );
    
    /**
     * Override the $databases variable to pass the correct Database credentials
     * directly from Pantheon to Drupal.
     *
     * Issue: https://github.com/pantheon-systems/drops-8/issues/8
     *
     */
    
    if (isset($_SERVER['PRESSFLOW_SETTINGS'])) {
        $pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
        foreach ($pressflow_settings as $key => $value) {
            // One level of depth should be enough for $conf and $database.
            if ($key == 'conf') {
                foreach($value as $conf_key => $conf_value) {
                    $conf[$conf_key] = $conf_value;
                }
            }
            elseif ($key == 'databases') {
                // Protect default configuration but allow the specification of
                // additional databases. Also, allows fun things with 'prefix' if they
                // want to try multisite.
                if (!isset($databases) || !is_array($databases)) {
                    $databases = array();
                }
    
                $databases = array_replace_recursive($databases, $value);
            }
            else {
                $$key = $value;
            }
        }
    }

For detailed instructions on setting up a Drupal Multisite configuration, refer to the Drupal Multisite documentation on the official Drupal project website. You will find comprehensive guides and examples to help you through the process.

Tags: 
Last Updated: 
Tuesday, February 11, 2025