1

I´ve read many questions about drush in a multisite configuration. This case isn't a multisite, but several different installations in a single VPS. Something like a reseller account. They are all my sites, but I don't want to mess them up. I need drush commands to be applied to a single site each time.

I´ve installed drush using my root access, under home/root/drush. So when I try to access ssh using one of my site´s credentials (not the root user, but one of the site´s admin), it doesn´t recognize drush commands.

Should I install drush in every single account, right outside /public_html, or should I edit the .bashrc file in any way? And in that case, how may I prevent the commands to affect other sites when I try to do something with a single specific installation?

I'm using Drupal 7 and Drush 5.x because of my php version (5.2.17).

I understand that I should have (inside the drush folder?) a file called aliases.drushrc.php, with something like this.

$aliases['site1'] = array(
    'uri' => 'mysite1.com',
    'root' => '/home/site1username/public_html',
    'remote-user' => 'site1username',
  );
$aliases['site2'] = array(
    'uri' => 'mysite2.com',
    'root' => '/home/site2username/public_html',
    'remote-user' => 'site2username',
  );

Is this correct? And how may I access drush only to a specific site?

2

"when I try to access ssh using one of my site´s credentials (not the root user, but one of the site´s admin), it doesn´t recognize drush commands."

The only requirements for using Drush from another user (than the one that installed it) is a) the drush directory should be readable, and b) drush should be in your PATH.

It is okay to install Drush once per user. I use a custom move-in script to accomplish this, but in my case it's rare for me to have more than one Drush-using user on one system. Setting the PATH in your bashrc to include the Drush directory of the root user is also fine. [Aside: it is best to avoid calling Drush using the root user, for security's sake. Any Drupal module can define code that runs during the execution of any Drush command.]

You aliases file looks okay, except that you only need to define remote-user for remote aliases. The aliases you are defining are local, so remote-user will be ignored. The alias file should go in the ~/.drush directory (inside the home directory of the user that is calling Drush).

You can download the Drush chapter of DGD7 for free; it is one of the book's sample chapters. It does a pretty good job at describing alias files and configuration. Although it was written for Drush 4, most of what it describes is unchanged in Drush 6 and Drush 7. Be sure to also read all of the Drush README.

Update: Forgot to mention: to use your aliases, type drush @site1 status. If your settings.php file is in a folder called default, then you may also access your site via cd /home/site1username/public_html && drush status.

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.