3

As an admin of a multi-site Drupal installation, I want to make module changes to all sites within that platform. On a regular basis, I want to disable/enable a set of modules to ensure consistency across all of the sites.

Using drush (any version 4.x, 5.x, or 6.x is acceptable), how can I perform this task without repeating the same command across each site?

8

Drush has the ability to interact with each site within a multi-site installation via the @sites argument. Anytime you are within the directory structure of your platform, the drush @sites command will target all sites rather than a single/no site. In this way, any drush task can be accomplished across all sites.

Some concrete examples:

  • Disable the dblog (core database logging) and devel module on each site

    drush @sites dis dblog devel -y
    
  • Enable the speedy module on each site

    drush @sites en speedy -y
    
  • Change the admin theme for all sites

    drush @sites vset --yes admin_theme "ember"
    
  • Check to see if any sites in the platform have the cdn module enabled

    drush @sites pml --no-core --type=module --status="enabled" -y | grep cdn
    

These (and many more commands) work with any version of drush >= 4.x

  • After updating to Drush 8 I also had to specify the root path to the installation - --root=/c/path/to/drupal - otherwise running commands with @sites would crap out after the Continue? prompt. Bypass by adding this to aliases.drushrc.php file: $aliases['sites']['root'] = '/c/path/to/drupal'; – othermachines May 2 '17 at 17:51
  • +1 for pml on all sites with drush @sites pml --no-core --type=module --status="enabled" -y | grep cdn and to point out that the -y is of outmost importance! Also note that the command does not need to be launched at the sites level but also in any directory within. – MediaVince Jul 11 '18 at 10:27
0

And also to add with above answer,

if you have 3 sites under sites folder. sites/all , sites/new , sites/dev and now assume "some_module" is installed and enabled in all 3 sites.

if you want to disable "some_module" only in "new" and "dev" sites

Step 1 : cd DRUPAL_DIR/sites/new

Step 2 : drush dis some_module

Step 3 : repeat Step 1 and Step 2 for dev sites as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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