Deployment¶
Know which parts of a Sites platform travel with exported configuration and which ones live in each environment's database.
| Configuration: exported and imported | Content: lives in each environment |
|---|---|
| Site types, with their setting defaults, assignable content and assignable roles | Sites, with their settings, configuration overrides, translations and values per environment |
| The pages under Sites configuration, such as General | Who is a member of which site, with which per-site roles |
| Roles and their permissions | Which content belongs to which site, and its canonical site |
| Modules, content types, menus, views, blocks | Menu links, URL aliases, redirects and all other content |
Configuration¶
drush config:export and drush config:import carry site types and the
platform settings like any other configuration. Change site types on
development and import them on the other environments.
Sites are content¶
A site is created on the environment where it runs:
- in the admin UI (Create a site);
- with
drush sites:createin a deployment script (Drush); - by copying the production database to the other environments.
A module can also declare sites in code; those ship with the code (Site plugins).
The ID of a site is set once, and settings.php addresses the site by it.
Give a site the same ID on every environment.
Values per environment¶
A database copied from production carries the production hostnames. Give each environment its own values in one of two places.
The Environments tab. Every settings section of a site has an
Environments tab, for the settings that the site type lets vary by
environment (its Environment overrides column). Environment Context
supplies the list of environments: its submodule
environment_context_config_split takes them from Config Split,
environment_context_environment_indicator from Environment Indicator. Each
environment names itself in settings.php, or in the DRUPAL_ENVIRONMENT
environment variable:
$settings['environment'] = 'stage';
settings.php. Values keyed by the site's ID win over every other layer
(Setting layers):
$settings['acme'] = [
'hostname' => 'acme.stage.example.com',
];
Site settings lists the keys and which of them can differ per environment. To see what a site resolves to on an environment:
drush sites:info acme --environment=stage
Caches¶
Give every environment its own cache backend: two environments on one cache serve each other's hostnames (Caching and performance).