Last updated 31 March 2017. Created on 14 August 2011.
Edited by eugenesia, rodtatham, isaac.el.cec, rudiedirkx. Log in to edit this page.

  • Install composer globally:
    $ curl -sS https://getcomposer.org/installer | php
    $ sudo mv composer.phar /usr/local/bin/composer
  • Install drush globally (for your user), you can specify the version:
    $ composer global require drush/drush:7.*
    
  • Add the composer path to your path (in your *.bashrc* or *.zshrc* or other):
    export PATH="$HOME/.config/composer/vendor/bin:$PATH"
    

While not recommended, Drush can easily be installed on Ubuntu by using Aptitude or apt-get. If you have sudo rights the quickest way to install Drush is from the Ubuntu repository:

$ sudo apt-get install drush

However, the version this currently will give you is 4.5 (using Ubuntu 12.04). Newer versions have many improvements so you should use Drush to upgrade itself to the latest stable:

$ sudo drush dl drush --destination='/usr/share'

Then you can check the update has been successful by executing:

$ drush --version

You could also install Drush manually by downloading it directly from the project page and following the instructions of the README.txt file.

For Ubuntu 10.04 LTS apt-get will provide 2.0 Drush version, you need to follow Ubuntu help support to enable backports and so have 4.4-1 version available, which can then by upgraded to 5.6 as described above.

$ sudo apt-get install -t lucid-backports drush

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

aiwata55’s picture

As of Sep/15/2011, Ubuntu 10.04 downloads and installs Drush 2.x with this method.

nidash’s picture

sudo apt-get install drush
on 11.04 gave me drush 4.4. must add doing 'drush dl drush' upgraded my drush version to 4.5

Anonymous’s picture

cool .. if you want you can just click the edit tab on top of the page and completely rewrite it

seaji’s picture

drush dl drush -- not working

message in ssh terminal:
There is no *recommended* release for project drush on Drupal 6.x. [ok]
Ask the maintainer to review http://drupal.org/node/197584 and
create/recommend a release in order to be compatible with drush and
the drupal.org security broadcast system. A recommended development
snapshot release is sufficient. Alternatively, run pm-releases
command and explicity pm-download any non-recommended release that
might be available.

seaji’s picture

Not working
sudo apt-get install drush - not working

Linux server 2.6.35-22-server #35-Ubuntu SMP Sat Oct 16 22:02:33 UTC 2010 x86
_64 GNU/Linux
Ubuntu 10.10

drush status
parse_ini_file(/usr/share/drush/includes/../drush.info): failed to [warning]
open stream: No such file or directory environment.inc:1012
PHP configuration : /etc/php5/cli/php.ini
Drush version:
Drush configuration :

PS "Installing Drush on Shared Hosting Accounts" not working as well (http://drupal.org/node/1181480)
not found "drush" command

~/drush/drush status
unknow command "status"

Bad Bad

diqidoq’s picture

as you wrote: you use Ubuntu 10.10

... and what does the docs say in one of the first lines? ;-)

bfr’s picture

Works fine on 10.04.

TipiT’s picture

If you run sudo apt-get install drush drush is installed /usr/share/drush as default. So /usr/share/drush/drush has to executable in your $PATH environment variables (I think it is but check is by running in shell export).

Update from 4.4 (available from Ubuntu repo)

After sudo apt-get install drush
1. Run sudo drush dl drush.
2. Run sudo drush.
3. drush --version

Update further

Drush might let you know that "A newer version of drush, 7.x-5.0-rc4, is available..." is available. Running
1. sudo drush self-update
2. sudo drush
3. drush --version

Should work.

Energyblazar’s picture

The above given steps work perfectly......but just one more simple thing, do restart your pc, and then type drush --version

zarrex’s picture

Hi, I can do the above but I want to instal the dev version of drush and cant find any docs anywhere. Can anyone help advise. This is because drush 5.1 now has drush_make in core and it doesnt work right: see bug http://drupal.org/node/1539076

darthanubis’s picture

You are running the provision script as the root user. Exiting

12.04

kpastore’s picture

Steps 1 and 2 worked for my Ubuntu 12.04 installation. Upgraded to version 7.x-5.8. Thanks!

nateB’s picture

But this one did: http://solutions-architecture.com/wiki/installing-drupal-drush-ubuntu-1004

Long and short:

  • Download Drush from the project page.
  • Upload and extract the Drush archive to /usr/local/lib/ (or wget it from there, I reckon)
  • Make drush executable: sudo chmod +x /usr/local/lib/drush/drush
  • Add a symlink in the /usr/bin/ directory: sudo ln -s /usr/local/lib/drush/drush drush
  • Navigate (to one) of your site(s) folder, cd /srv/www/yoursite.com/sites/default
  • Check status of Drush with drush status
  • Check the version of Drush with drush --version. For me, it's 5.8.
markbannister’s picture

In order to not have to run as root or sudo rights see http://drupal.stackexchange.com/questions/20496/is-it-possible-to-run-drush-without-root

summary:
In user's home directory who will run drush and ahs web privileges change permissions of .drush and drush-backups (created during install) for that user
sudo chown -R username:usergroup ~/.drush
sudo chown -R username:usergroup ~/drush-backups

grzesag’s picture

if you are running Ubuntu 13.04 you can install drush using apt-get but it installes drush version 5.8.

To upgrade to version drush 5.9 please do following:
sudo drush dl drush --destination='/usr/share/php'

Hope it helps someone

remerjohnson’s picture

I installed via apt-get method on Ubuntu 13.10. Install worked fine, but when executing drush version, I get:

PHP Fatal error:  Call to undefined function json_encode() in /usr/share/php/drush/includes/output.inc on line 708
Drush command terminated abnormally due to an unrecoverable error.                                [error]
Error: Call to undefined function json_encode() in /usr/share/php/drush/includes/output.inc, line
708

I went to that json_encode() function and found the following:

/**
 * Converts a PHP variable into its Javascript equivalent.
 *
 * We provide a copy of D7's drupal_json_encode since this function is
 * unavailable on earlier versions of Drupal.
 *
 * @see drupal_json_decode()
 * @ingroup php_wrappers
 */
function drush_json_encode($var) {
  // json_encode() does not escape <, > and &, so we do it with str_replace().
  return str_replace(array('<', '>', '&'), array('\u003c', '\u003e', '\u0026'), json_encode($var));
}

Any thoughts on what to edit?

couloir007’s picture

I'm having the same problem.

alfonsojosegarcia’s picture

I too, any solution? Help!!

amitsedaiz’s picture

Installing the package separately will do the trick.
For Ubuntu: sudo apt-get install php5-json
Link: http://stackoverflow.com/questions/18239405/php-fatal-error-call-to-unde...

andykisaragi’s picture

Anyone like me currently getting this error when trying to install with PEAR:

Array to string conversion in /usr/share/php/PEAR/REST/13.php on line 80

This is due to a bug in drush: https://github.com/drush-ops/drush/issues/465

pavithra.raman’s picture

I had issues in installing drush via PEAR, but it looks like the pear channel is not maintained or has a bug.
More in the discussion on the github repo for drush
https://github.com/drush-ops/drush/issues/465

Copying the instructions to install drush via github below

Install composer and drush (debian but should be the same for most linux's)

Note: directories are up to you This was mine ...

clone git somewhere
git clone https://github.com/drush-ops/drush.git /usr/local/drush

create a link to drush from the bin dir
ln -s /usr/local/drush /usr/local/bin/drush

install composer
curl -sS https://getcomposer.org/installer | php

move it into the path and rename it
mv composer.phar /usr/local/bin/composer
(or you can link it like with drush above)

get dependencies
cd /usr/local/drush
composer install

You should be ready to go
Please add to this instruction with anything required for your own OS

pavithra.raman’s picture

They have updated the PEAR channel. It should work now.

leolando.tan’s picture

I'm using Ubuntu 12.04. I have installed php-pear already but when i issue

pear channel-discover pear.drush.org

I get this error:
could not create lock file: fopen(/usr/share/php/.lock): failed to open stream: Permission denied

How can I fix this?

Thanks

leolando.tan’s picture

I just issued the commands with "sudo".

ernestto’s picture

I try to use pear channel-discover pear.drush.org but not work I install drush with apt-get commands

rmfranciacastillo’s picture

Thank you! This has been very helpful! Just using:

sudo apt-get install drush

I was able to install drush in Ubuntu 14.04.
Cheers!

mralexho’s picture

Run the following command -

drush pm-download --select --all drush

Choose one of the available releases for drush:
 [0]   :  Cancel                                                
 [1]   :  7.x-5.x-dev            -  2013-Sep-30  -  Development 
 [2]   :  7.x-5.9                -  2013-Apr-17  -              
 [3]   :  7.x-5.8                -  2012-Nov-12  -              
 [4]   :  7.x-5.7                -  2012-Aug-18  -              
 [5]   :  7.x-5.6                -  2012-Aug-10  -              
...
...
...

Then select the release you'd like to download.

suresh kumara’s picture

I have installed drush several times but in ubuntu 14.04. I am getting error as below

/var/www/drupalenglish$ drush status
Drush needs to download a library from [error]
http://download.pear.php.net/package/Console_Table-1.1.3.tgz in order
to function, and the attempt to download this file automatically
failed because you do not have permission to write to the library
directory /usr/local/lib/php/drush/lib. To continue you will need to
manually download the package from
http://download.pear.php.net/package/Console_Table-1.1.3.tgz, extract
it, and copy the directory into your /usr/local/lib/php/drush/lib
directory.

johnhanley’s picture

Did you use sudo when installing drush?

abhai_zyxware’s picture

Follow the instructions here. Its quite simple to install the latest drush. http://www.zyxware.com/articles/4497/drupal-installing-latest-version-of...

kiwimind’s picture

When following the instructions above, please ensure that when adding the directory to your path that it's different than stated:

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

raphaelbluteau’s picture

Thanks kiwimind, that worked for me!