Install Drush for all users

Usually I install Drush using Composer but the problem it need to be installed per user. Recently I came across a situation while configuring Jenkins that the jenkins user should also have access to Drush to run the build. So, instead of installing it again for jenkins I was looking for a solution where all the users in the system can have the benfits of Drush. Still, Composer is the best way to do it with some minor tweaks.

First, install Composer globally:

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

Next, symlink to System-wide binary

ln -s /usr/local/bin/composer /usr/bin/composer

Then, clone the Drush git repository and place in /usr/local/src to install. Create a symlink of the src folder to the binary

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

Now when you do drush --version you will get the Latest Drush version which is same for all the users in the system.