How to set up Drush for a multisite installation

Most of the time the default download path that Drush uses for modules is perfectly fine (sites/all/modules), and until this week I’ve never had a reason to alter it. However, I happen to be working on an Aegir multisite install right now and I’ve been given access to only the site specific folder for that domain (meaning I don’t have remote access to sites/all/modules). In this case downloading modules to the sites all folder while developing on my local machine is not a good idea as it would require remembering which modules needed to be moved.

After searching a bit through quite a few contradictory posts giving instructions which didn’t seem to work I decided to go ahead and write out what worked for me. Chances are somewhere down the line I’ll end up googling the question again and find this article (it’s happened to me more than once already).

To start, go to your drush folder where you will find a file entitled example.drushrc.php. Copy that file into the individual site folder in your Drupal multisite installation (sites/yourmultisite), and rename the file to drushrc.php.

Now open that file and add the following line:
$command_specific[‘dl’][‘destination’] = ‘sites/yourmultisite/modules’;

or

$command_specific[‘dl’][‘destination’] = ‘sites/yourmultisite/modules/contributions’;

Adding the contributions folder is optional, but it helps keep things organized if you have a lot of custom modules you are working on.

Now in a single site installation downloading a module is done by typing “drush dl examplemodule”, however in a multisite environment the command is slightly different: “drush -l yourmultisite dl examplemodule”.

That’s really all there is to it. Any command that you want to affect only a particular domain you call it by adding the -l modifier followed by the foldername of that site.

Hope this helped.