5

By following the instructions on the Drush git page:

composer global require drush/drush:6.*

I have Drush up and running (it seems to live in /root/.composer/vendor/drush/drush). But I imagine I shouldn't be running it via root. So how do I run it as my ordinary shell users?

When I try running drush it says command not found. Although it lets me use Composer. I tried installing Drush again through Composer while logged in as ordinary user without any luck. The Drush folder is also inaccessible..

  • 1
    Have you read the installation docs? I'm 99% certain this is covered – Clive Jun 9 '14 at 17:47
  • I fixed it just now.. the PATH to composer's bin was incorrectly added, when I added it for the logged-in-user it started working. At least I think it was that, because .composer and .drush directories suddenly appeared in my home directory. – KlineAl Jun 9 '14 at 18:02
7

To install for all users on the server:

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
ln -s /usr/local/bin/composer /usr/bin/composer

git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
cd /usr/local/src/drush
git checkout 7.0.0-alpha5  #or whatever version you want.
ln -s /usr/local/src/drush/drush /usr/bin/drush
composer install
drush --version

Personally I don't bother making the composer symlink from /usr/local/bin to /usr/bin and made the drush symlink to /usr/local/bin (rather than /usr/bin) as I have /usr/local/bin in my $PATH but YMMV...

Source: http://docs.drush.org/en/master/install/

  • This is strange. Why do we need to use git clone at all? Is there no way to do this with compser require, or by adding a line in composer.json? This is what most tutorials / online instructions say, except that they will all give you drush in user home directory. – donquixote Oct 23 '17 at 20:53
  • @donquixote - AFAIK you nailed it when you said "except that they will all give you drush in user home directory"! I am not aware of any way to explicitly install it to a specific location as my answer does. TBH, I'm not sure why, but I've always assumed that it's a limitation of composer itself?! – Jeremy Davis Oct 24 '17 at 3:08
  • stackoverflow.com/questions/33380480/… maybe this helps – donquixote Oct 24 '17 at 15:19
  • Interesting... Personally, I'll still continue to use the above as I like to keep custom global binaries limited to /usr/local because IMO it's much cleaner. A quick read of the drush docs suggest that they now have a tool that allows all users to globally use drush from within a composer project, so it sounds like what you want is totally possible with current drush. IMO though, it's better to do it right (even if it requires an extra line), rather than work around the issues created by doing it hacky in the first place. But that's only my opinion... – Jeremy Davis Oct 26 '17 at 1:57

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.