Jojodae Ganesh Sivaji
May 18, 2013
One of the admiring features of Drupal is its ability to leverage a single code base to power a stack of sites. Drush the excellent command line utility eases the work of administering Drupal sites.
Our recent work raised a question, will these two blend & work together?
Of course, we tried this, and the answer is yes but to be used with more caution!!
In the case of Drupal multisite, Apache (or any Web server) is configured such that more than one domain name points to the same document root. Drupal by identifying the request originating domain and folder structures loads the respective modules/themes & database. Drush utilizes a similar approach.
In the case of multisite, to run a drush command against a specific site/database there are two ways,
In this case cd to the site folder. Ideally from inside the folder sites/one.example.com or similar the drush commands to be issued. This will run all the commands against one.example.com site.
Assume a multisite setup with a separate database per site. Then
$ drush sql-connect
would return
user@hostname:/var/www/sites/one.example.com$ drush sql-connect
mysql --database=example_one --host=localhost --user=example_one --password=example1
This works by passing the argument -l (or --uri). The request originating domain is mentioned explicitly here and hence takes more precedence over #1.
user@hostname:/var/www/sites/one.example.com$ drush sql-connect -l https://two.example.com
mysql --database=example_two --host=localhost --user=example_two --password=example2
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!