Installing Drush on Ubuntu

Manuel Garcia's picture

So, you probably have heard of drush, and maybe you have not tried it yet. I tried it quite a while ago, and found it to be somewhat of a hassle. But I yesterday I decided to give it another go, and see all the buzz everyone's talking about.

I use ubuntu at home, and using the console to manage drupal sites seems like ideal, yet I didn't think drush was ready yet... seems like I wasn't paying enough attention!

So now to the meat of it. You will have to change username for the name of your user of course.

  1. Download drush, and uncompress it to your home directory. In my case, this leaves the files inside /home/manuel/drush
  2. Make sure the permisions to the drush file are set so that you can execute the file. See the screenshot below:
  3. If only you will be using the script, make a symbolic link to this file in your /home/username/bin (create the folder if you haven't already):
    ln -s /home/username/drush/drush /home/username/bin/drush
    After which, you should have a drush file in your bin directory like on the screenshot:
  4. UPDATE: To install Drush system wide, simply move the entire Drush directory to /usr/local/lib, and place your symbolic link in /usr/local/bin (thanks cjdavis)

And that is it my friends. You can now go to the root of your drupal installation, and let your jaw drop by executing drush sql dump, and then drush update, and look at it update all the modules on your site in 1 minute, while you go grab a beer.

A command you will want to use is drush help to find out what commands you have available. Enjoy, and long live drush!

[EDIT]
From Ubuntu Lucid on, you can install drush from Synaptic, or the command shell like sudo apt-get install drush However, in Lucid you'll only get the 2.x branch. In Maverick you get the 3.x branch. Not sure how maintained these packages are, if you care to help or wonder how this is going, head over to https://launchpad.net/ubuntu/+source/drush

AttachmentSize
folder-permissions.png76.52 KB
symbolic-link.png83.25 KB

Comments

Install to /usr/local for system-wide availability

cjdavis's picture

On my server, I am hosting many sites for clients, so each one is running in a separate user account - I need Drush to be available to all users on the system. Perhaps Aegir would help simplify even more, but that's another project..

To install Drush system wide, simply move the entire Drush directory to /usr/local/lib, and place your symbolic link in /usr/local/bin - that's it.

Thanks, updated

Manuel Garcia's picture

I've updated the post to include that information -- thanks!

Thanks for this - for some

stephenplatz's picture

Thanks for this - for some reason I'm getting the following when I use this installation method:

Unable to download drupal-6.17.tar.gz to /var/www/ from              [error]
http://ftp.drupal.org/files/projects/drupal-6.17.tar.gz
An error occurred at function : drush_pm_download                    [error]

Everything seems to be in place, not sure what to try next. Has anyone else seen this?

Are you perhaps trying to

mcrittenden's picture

Are you perhaps trying to download it to a folder which you don't have permissions for? If so, maybe try "sudo drush whatever" instead of "drush whatever", or just try a "chown -R yourusername /var/www" to make yourself (not root) the owner of /var/www.

Yes, one of those dumb 'why

stephenplatz's picture

Yes, one of those dumb 'why didn't I do that first' moments - changing the owner of the /var/www directory worked, of course. I'm on a new install of Ubuntu, but I don't remember that issue with using Drush before. Thanks again!

so this would change the ln -s to . .

BeWhy's picture

so if i was going to do this, I'd change the symbolic link to read:

ln -s path/to/drush/drush /usr/local/bin

?

what you don't know will inspire you

destination path or filename

Silicon.Valet's picture

ln -s path/to/drush/drush /usr/local/bin/ <- note the slash
ln -s path/to/drush/drush /usr/local/bin/drush

It is not working for me.

stanleychen's picture

I download the latest release 7.x-4.5 and follow the instruction in Ubuntu but not working, and idea?

In Ubuntu 9.10 I had to do this:

johnvsc's picture
  • Grab the Ubuntu Install disk :) and place it in the drive
  • Install the php5-cli libray (CLI means Command Line, btw) $ sudo apt-get install php5-cli
  • Follow the direction above but...
  • Use the following to create a symbolic link: $ sudo ln -s /home/johnvsc/drush/drush /usr/bin/drush or, in other words : sudo ln -s /home/username/drush/drush /usr/bin/drush

The bin was in a different place on my install :)

enjoy!

Update PHP Cli memory limit

MichaelP's picture

When I ran "drush features", just for fun, I got:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 311296 bytes)

This requires upping the php memory limit for cli which in my case is in: /etc/php5/cli/php.ini

Set it to: memory_limit = 256M;

That sorted it!

Thanks for the post!

Don't forget to set this, as

liberatr's picture

Don't forget to set this, as we were having a similar Drush Memory Limit issue on our production server. Until I knew that command-line had a separate memory limit, I was baffled. Thankfully, I have some smart friends.

Hi Manuel :) The actuality,

eloiv's picture

Hi Manuel :)

The actuality, drush is in repository of ubuntu, but is version 2.0 and drush make do not work.

Very true

Manuel Garcia's picture

You could just do sudo aptitude install drush but you'd only get drush 2.0-6 (in lucid).

All the goodies are in Drush 3, so I stil would go with manualy installing, not that much to it =)

This gets me thinking... perhaps we should set up a PPA on launchpad with the the latest Drush... any takers?

[EDIT]

The 3.x branch is coming up on maverick, see https://launchpad.net/drush
I'm not very familiar with launchpad, but we should definetly setup a PPA for the latest stable Drush.

[EDIT2]
I have asked for this on there https://answers.launchpad.net/drush/+question/120987

davad's picture

There's a ppa repository that has drush 4.4 at https://launchpad.net/~brianmercer/+archive/drush
You can add it from the commandline using sudo add-apt-repository ppa:brianmercer/drush; sudo apt-get update; then install it from the commandline using sudo apt-get install drush

Edit: Whoops, just saw that you posted a link to this further down.

I've also updated the post

Manuel Garcia's picture

I've also updated the post with the information, thanks!

Install drush on Ubuntu 10.10

newmember's picture

Go to this page and find the link to the release version you want:
http://drupal.org/node/97249/release

Then:
cd /usr/local/lib/
wget http://ftp.drupal.org/files/projects/drush-6.x-4.0-rc8.tar.gz <---- Change to the release you want
tar zxvf drush-6.x-4.0-rc8.tar.gz
cd drush/ <-----There is drush, just checking
cd /usr/local/bin
ln -s /usr/local/lib/drush/drush drush

Then:
Go to the root folder of your website
cd /root/folder/of/drupal/
drush

I dont know drush all that well but here are a few fun ones:
drush status <----- what version of drush are you running
drush dl drupal <------ will download current release of drupal

PPA

Manuel Garcia's picture

I see that someone has setup a PPA for drush 4.x branch, mind you I haven't tried it, nor do I know the person behind it. Just thought I'd let you guys know about it:
https://launchpad.net/~brianmercer/+archive/drush

I've been applying the new

brianmercer's picture

I've been applying the new source packages to the debian package and uploading to my ppa. Haven't had any problems myself.

Antoine's been updating his debian repo also. http://packages.debian.org/sid/drush

If anyone has any issues with my ppa, let me know.

Having error.

siva.thanush's picture

Hi i m getting error while i tried any of the drush commands.
"cannot redeclare drush_test_clean() (previously declaredin /etc/drush/commands/core/test.drush.inc:50) in /usr/share/drush ......"

Siva
Sify

Search the drush issue queue

Manuel Garcia's picture

Search in the issue queue, see if anyone else has seen that problem. If you cant find anything, create a new issue there.

Try cleaning out old drush 3 files first

Jonathan Peterson's picture

I had this same error when upgrading from Drush 3 to Drush 4. There were some old drush 3 files that were still sitting in my drush directory. To address this I just deleted my drush install and then re-installed Drush 4. All copacetic now.

Hope this helps.

It sure did, thank you.

jgrubb's picture

It sure did, thank you.

John

Same problem

arsunyiu's picture

Hi all, I am using ubuntu 10.04.2.
I got the same problem, anyone know the solution??

remove the drush via sudo

philosurfer's picture

sudo apt-get purge drush

then install manually...

or if you have Ubuntu 11 you can reinstall from apt-get and it will pull version 4.4


          "we are the cult of personality."

Works for me! Many thanks.

nourcy's picture

Works for me! Many thanks.

Drush in ubuntu repository

kurkuma's picture

The version 4.4 of drush is available as per sudo apt-get install drush.
Installed from Ubuntu 11.04 w/o probls.

Jorge

How I installed drush on ubuntu 10.04 server

pfiliatreault's picture

1- If in a vm, take a snapshot

2- Upgrade your ubuntu server. login via ssh as admin.

$sudo apt-get update
$sudo apt-get upgrade

3- install PEAR.

$sudo apt-get install php-pear

4- tell PEAR to update its own channel.

$sudo pear channel-update pear.php.net

5- tell PEAR to upgrade itself to the newest version.

$sudo pear upgrade-all
You should now have the newest version of PEAR installed.

6- Install drush

$sudo pear channel-discover pear.drush.org
$sudo pear install drush/drush

7- install Console_Table

$sudo pear install Console_Table

8- Update your drupal core

$cd /var/data/drupal

$drush pm-update

That's it. Pretty easy. Thanks everybody for your help.

Ubuntu 10.04LTS

CZ's picture

In Ubuntu 10.04LTS, Drupal 7.14 and Drush 5.4

Manual installation

  1. download drush (http://ftp.drupal.org/files/projects/drush-7.x-5.4.tar.gz)
  2. unpack and copy the directory "drush" to "/usr/share/"
  3. Make the 'drush' command executable:
    $ sudo chmod u+x /usr/share/drush/drush
  4. Make the director "/usr/share/drush/lib" readable.
  5. create a symbolic link:
    $ sudo ln -s /usr/share/drush/drush /usr/bin/drush
  6. Go to your website and test it
    $ cd /var/www/drupal7
    $ drush status
  7. disable the file /etc/php5/cli/conf.d/ldap.ini if required by ";" before "#".