Install Drush globally in Ubuntu

March 30, 2019

Drush is a great tool and is well worth setting up in your development environment, it speeds your workflow up incredibly and gets easier to use over time as you learn by heart the various and most commonly used commands.

I couldn't find a tutorial online which gave me the correct path for my .bashrc file so I thought I would document what worked for me here, maybe it will help someone out.

My first step was to install composer globally, if you are not all that familiar with the command line you don't need to include the $ sign.

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

Next step is to install drush globally.

$ composer global require drush/drush

Now we need to add a path to the Bashrc file, this basically enables us to use drush as a shorthand command rather than it's full path. If you don't have a .bashrc file in your home directory then you will need to create one.

Most other tutorials I found were telling me to use the following for my PATH.

export PATH="$HOME/.config/composer/vendor/bin:$PATH"

However upon investigation my Drush folder was not in this directory and was actually 

export PATH="$HOME/.composer/vendor/drush/drush:$PATH"

If neither of these work you will need to do some investigating to find out where Drush was installed, if you can't see the .composer or .config folders you will need to show hidden files, in Ubuntu you can usually do this by clicking on one of the icons in the top right of your folder, then look for 'show hidden files' or something to that effect.