Drupal 8 – How to get Drush to run on a Linux distro

Getting Drush to work in Linux for Drupal

Now that Drush has removed support for Pear, and running the drush.php manually is currently not working, you are “forced” to use Composer.

If you don’t follow this way, you will get an error like: Unable to load autoload.php. Drush now requires Composer in order to install its depedencies and autoload classes. Please see README.md

If you do not currently have composer installed you will need to download and install it, see https://getcomposer.org/doc/00-intro.md for instructions.

You will need to run the following:

cd ~ curl -sS https://getcomposer.org/installer | php

Now we will set the path to .composer:

sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc

Now to work with Drupal 8, you will require the latest Drush (7.x) at the time of writing this, which you can install like:

~/composer.phar global require drush/drush:dev-master --prefer-source && source ~/.bashrc
EDIT: 9/4/17 This code will pull in drush 9.x.dev

To update drush (as Drush is usually updated several times a day), simply run:

cd ~/.composer ~/composer.phar update