How to install Composer and Drush LOCALLY and GLOBALLY

Drush 9.x Install Composer to your LOCAL user directory

cd ~
mkdir .composer
curl -sS | php
mv composer.phar ~/bin/composer
chmod +x ~/bin/composer
echo "PATH=$PATH:~/.composer/vendor/bin" >> ~/.bash_profile
. ~/.bash_profile

Install latest version of Drush locally

Get the latest (or whatever) version here:

composer require drush/drush

And we done...


cd ~
mkdir bin
chmod +x bin
cd bin
chmod +x drush.phar
mv drush.phar ~/bin/drush
# Following will further setup drush and add "~/.drush/" contents and update your "~/.bashrc"
# Backup .bashrc in case something goes wrong and then finish setting up drush.
cp .bashrc .bashrc-bak
drush init

Now lets reload our .bashrc and check the drush version:

. ~/.bashrc
# which is same as:
# source ~/.bashrc
​drush version


cd ~
git clone drush
# or to install another version; example 8.x which is PHP 5.5 compatible
# git clone -b 8.x  
cd ~/drush
composer install

To update drush after install:

cd ~/drush
git pull master
composer update


Help docs:

Get the latest (or whatever) version here:

mkdir /usr/local/src/drush
cd /usr/local/src/drush

# wget -O drush.phar[VERSION]/drush.phar
wget -O drush.phar

chmod +x drush.phar
cp -Rf drush.phar /usr/local/bin/drush


For Godaddy hosting, do the following (DEPRECATED: use local instructions above):

*** THIS MAY BE OUTDATED *** Use above local install instructions instead

cd ~
git clone drush
curl -sS | php
mv composer.phar composer
cd drush
composer install

To update an existing drush git installation

cd ~/drush
git pull master

Update your .bash_profile so it looks like this

# .bash_profile

#start drush #

export DRUSH_PHP="/usr/bin/php5"

export COLUMNS

alias drush="/usr/bin/php5 ~/drush/drush.php"
alias composer="/usr/bin/php5 ~/composer"

alias php="/usr/bin/php5"

# end drush # 

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc

# User specific environment and startup programs


export PATH

Now let's test it.


If all went well, last command 'drush' should bring up all the drush commands.

setup Drush aliases

Now we need to tell Drush where the new site will be located... Drush doesn't overwrite the original site, so we need to tell it where the DEV/TEMP location will be.

vi /usr/local/share/drush/aliases.drushrc.php

Paste this code into it (hit "i" on your keyboard to insert)

$aliases['siteA'] = array(
  'uri'  => 'localhost',
  'root' => '/home/siteA/public_html', // This must be a full full path, not a relative one

$aliases['siteB'] = array(
  'uri'  => 'localhost',
  'root' => '/home/siteB/public_html', // This must be a full full path, not a relative one

$aliases['siteC'] = array(
  'uri'  => 'localhost',
  'root' => '/home/siteC/public_html', // This must be a full full path, not a relative one
  'db-url' => 'mysql://DBUSER:DBPASS@localhost/DBNAME', //this is your new DB that you will have to create before the upgrade

$aliases['allsites'] = array('site-list' => array('@siteA','@siteB','@siteC'),);

Example Usage

drush @siteA pm-update #This will update drupal and all modules on 'siteA' 
drush @allsites pm-update #This will update all sites under 'allsites' alias

See here for Drupal major version upgrades using drush.


"No Drupal site found, only 'drush' cache was cleared." can mean that you're unable to connect to the database. To confirm use the following command:

drush -v -d sql-cli

If you get an error message stating that "composer" is required, then you didnt' install composer correctly.

Unable to load autoload.php. Drush now requires Composer in order to install its depedencies and autoload classes. Please see

If you get this error message :

git-remote-https: /usr/local/lib/ no version information available (required by git-remote-https)
git: /usr/local/lib/ no version information available (required by git)

You can fix with DirectAdmin's custombuild

cd /usr/local/directadmin/custombuild
./build update 
vi options.conf

Change the below settings to the following.

#versions of zlib, apr_util and libxml2 (experts only)

Then do the following:

./build zlib; ./build libxml2; ./build php n

And that should fix it.

Tags: Drupal Administration Linux drush composer