8

I have a Drupal Multisite set up. It contains two sites, but the core Drupal install has no site.

With Drush, I can use @sites to target all sites. For example:

  • drush @sites -y cc all - Updates all multi-sites
  • drush @sites -y en jqmulti - Install Jquery in all Multi-Sites

However, because I have no site installed in the core folder, I always get an error message stating that the core site is missing. Is there any to use Drush to only update the sub-multisites and skip the core one?

I know I can run Drush from the sites directory of the sub-sites, but that isn't very convenient when I want to target all sites.

The reason I am using Multisites is because both sites share themes and user-logins.

2 Answers 2

8

When you say "core site", do you mean the site in sites/default? Is it an option to just delete the settings.php file at sites/default/settings.php?

If you'd like to manage your aliases in an alias file, create a file ~/.drush/mysite.aliases.drushrc.php:

$root = '/path/to/root';

$aliases['site1'] = array(
  'root' => $root,
  'uri' => 'site1.com',
);

$aliases['site2'] = array(
  'root' => $root,
  'uri' => 'site2.com',
);

See this link for an example.

Then, to refer to one site:

drush @site1 status

  • or -

drush @mysite.site1 status

To refer to all sites:

drush @mysite status

Maybe you want to get more fancy than this, though. If you have more aliases in your alias file (e.g. for 'dev' and 'live' sites, you can make your own lists:

$aliases['dev'] = array(
  'site-list' => array('site1', 'site2'),
);

Then:

drush @mysite.dev status

If you want, you may also store your alias file in /path/to/root/drush or /path/to/root/sites/all/drush, but if you do this, Drush won't be able to find your alias file unless you specify --root on the commandline, or change your working directory to be somewhere inside of /path/to/root.

1
1

You need to setup a new Drush alias file for running the command on the remote site. Typically you name the file as <project_name>.drushrc.php.
You then need to place this file in the .drush directory in the home directory of your logged in user.

See this link for a sample Drush alias file.

After setting up the file, do a drush cc drush to clear the Drush cache and let it allow picking up the new alias files (Note: This might not be required on some environments)

UPDATE: If you are hosting your remote site on Acquia or Pantheon, you get to download the alias file directly.

To download the alias file for

  1. Acquia, go to https://accounts.acquia.com/account/<login_id>/security?site=insight and you download the alias from the link: acquia
  2. For Pantheon go to https://dashboard.pantheon.io/users/<user_id>#sites/list and download the alias file pantheon
3
  • Do I create a Drush directory in my Drupal site? Do I specify each of multis-ties in the Alias file? thanks for your help!
    – big_smile
    Commented Mar 25, 2015 at 12:07
  • @big_smile You don't have to create a Drush directory for your site. The directory should be present in the home directory of the current unix user. You could setup multisite in a single alias file.
    – AjitS
    Commented Mar 25, 2015 at 13:57
  • @big_smile If you are hosting your site on Acquia or Pantheon you get to use the alias file they provide directly! Just copy it to the .drush directory, and you are good to go
    – AjitS
    Commented Mar 25, 2015 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.