Last Updated: February 01, 2019
·
7.903K
· jhnbrnn

Drush multi-site aliases

If you're running a multi-site Drupal setup, here's how to set up your Drush aliases to easily run commands for specific sites:

/**
 * Local
 */
// The site in sites/default/
$aliases['default.local'] = array(
  'uri' => 'default',
  'root' => '/path/to/drupal',
  'path-aliases' => array(
    '%dump-dir' => '/tmp'
  ),
);
// The site in sites/site1/
$aliases['site1.local'] = array(
  'uri' => 'site1',
  'root' => '/path/to/drupal',
  'path-aliases' => array(
    '%dump-dir' => '/tmp'
  ),
);

/**
 * Remote
 */
$aliases['default.prod'] = array(
  'uri' => 'default',
  'root' => '/path/to/drupal',
  'remote-host' => 'example.com',
  'remote-user' => '[server_user]'
);
// The site in sites/site1/
$aliases['site1.prod'] = array(
  'uri' => 'site1',
  'root' => '/path/to/drupal',
  'remote-host' => 'example.com',
  'remote-user' => '[server_user]'
);

In short: the "root" value for all the sites is the root of your Drupal installation. The "uri" value of the alias should match the folder in which the site is stored. To test, you can call drush @default.local status and drush @site1.local status to confirm it's accessing in the right directories.

1 Response
Add your response

Excellent post. To the point. Gets me moving forward. Thanks for posting!

over 1 year ago ·