Use composer to install drush on Linux

By donmc, 15 June, 2014
I have been building a new web server platform and tried to install drush using pear as I have in the past, but it is not NOT the recommended way to install it any longer (who knew?).
Drush has developed a huge cult following for it's ease of use in maintaining multiple drupal based sites very easily from the CLI. I cannot recommend drush highly enough - I can update the code for all of my sites in a few minutes - back in the gory days it would take me ages to do that... These steps worked flawlessly for me on Ubuntu 14.04 today.

The composer references -- the first two bullets -- are from here:
https://getcomposer.org/doc/00-intro.md#system-requirements # See section titled "Globally"
Below that is an excerpt from github (the new home of drush code):
https://github.com/drush-ops/drush#installupdate---composer
  • You can run these commands to install composer for execution from anywhere on your system:

    curl -sS https://getcomposer.org/installer | php
    sudo mv composer.phar /usr/local/bin/composer
    
  • Make sure Composer's global bin directory is on the system PATH (recommended):

    sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc
    source $HOME/.bashrc
    
  • To install Drush 6.x (stable): (Recommended Version for Drupal 7 users)

    sudo composer global require drush/drush:6.*
    
  • To install Drush 7.x (dev) which is required for Drupal 8:

    sudo composer global require drush/drush:dev-master
    
  • To update to a newer version (what you get depends on your specification in ~/.composer/composer.json):

    sudo composer global update