NOTICE: Drush no longer supports installation via pear. As a result, much of this content is out of date. Please refer to the official documentation for installing Drush via composer.
Ok, so I am just conveying my experience in installing the quintessential tool that is drush. I work at Kalamuna and I provide support to a majority of our clients. I am constantly having to move sites around from server to server, platform to platform, etc.
One of the biggest challenges I faced early on (and still do) is how do I get drush to install on a certain server? Some are very easy, some are great because they come with drush, but most are not.
So this may not be the end all to be all resource, but this is a quick and easy way I have found for a few different instances in the Linux/Unix universe. A lot of this is on the github for drush, but this is a condensed and easy to use way from my experiences.
First off you will need SSH access for your client and or the site you are working on, without this, there is no point. If you don’t have root access (although great) you can still pull this off.
Second, you need at least php 5.2 to run any version of drush going back to drush 3.x. To check your php version, at the command line, type in:
php -i or php -v
Once you know your CLI php is 5.2 or greater, you are good to go on. Note Drush 6.x branch requires php 5.3.3. My instructions include how to install specific version of drush.
Also, make sure you know what OS and version your server is running too. You can do this a few ways on a Linux based distro, run each command until you find one that gives you your OS and distro:
uname -a
lsb_release -a
cat /etc/*release
cat /etc/issue*
cat /proc/version
Most Linux Versions with root
This is easiest and best way to get this to work. Real simple:
1. Check if PEAR is on the server with: pear version
2. If PEAR is not on the server then type in:
Debian based:
sudo apt-get install php-pear
RedHat based:
sudo yum install php-pear
SUSE based:
sudo zypper install php5-pear
3. Then type in: pear channel-discover pear.drush.org
4. and then finally: pear install drush/drush
4a. if you would like to install a specific version, you can do this (for instance drush 6.x requires php 5.3.3, so you may want to use the 5.x branch instead): pear install drush/drush-5.7.0
If something goes awry, you can always uninstall drush with: pear uninstall drush/drush
CentOS Linux
There are 2 ways to do this on centOS, one preferably being the pear install below
Pear CentOS Install #1 (similar to above except #2)
-------------------------------
1. Check if PEAR is on the server with: pear version
2. If PEAR is not on the server then type in: yum install php-pear
3. Then type in: pear channel-discover pear.drush.org
4. and then finally: pear install drush/drush
4a. if you would like to install a specific version, you can do this (for instance drush 6.x requires php 5.3.3, so you may want to use the 5.x branch instead): pear install drush/drush-5.9.0
If something goes awry, you can always uninstall drush with: pear uninstall drush/drush
Pear CentOS Install #2
--------------------------------
$ sudo wget --quiet -O - http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz | sudo tar -zxf - -C /usr/local/share
$ sudo ln -s /usr/local/share/drush/drush /usr/local/bin/drush
$ sudo drush
Also note sometimes you may not be able to tar the file in /usr/local/share due to restrictions / perms. In that case, you can do something like this:
$ cd ~
$ wget --quiet -O - http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
$ tar -zxf drush-7.x-5.9.tar.gz
$ ln -s ~/drush/drush /usr/local/bin/drush
$ drush
Installing on shared hosting (like Godaddy, RackSpace, etc) or non root and / or limited perm SSH
This is where the fun lies and can always be a pain. You can try what I did in the alternative in Pear CentOS Install #2
OR you can do this:
1. get a zip or tar.gz of the drush version you want form say: https://github.com/drush-ops/drush/tree/5.x
2. FTP or Rsync (if you can) your uncompressed folder into ~/ on your server. You should see the drush folder as ~/drush. FTP is usually easier on limiting servers.
3. in your ~/ either download or edit in the CLI the .bash_profile (or .bashrc)
4. at the end add the following lines:
export COLUMNS
alias drush='/usr/local/php5/bin/php ~/drush/drush.php --php=/usr/local/php5/bin/php'
alias php='/usr/local/php5/bin/php'
On some newer GoDaddy Cpanel based accounts, if you receive an error that /usr/local/php5/bin/php can't be found, then use this:
export COLUMNS
alias drush='/usr/bin/php5 ~/drush/drush.php --php=/usr/bin/php5'
alias php='/usr/bin/php5'
5. save the file and (if you ftp’d it, put it back up on the server)
6. at the CLI run: source .bash_profile
or logout and log back in
That is about it as far as I can think of right now. This has helped me with numerous instances of numerous scenarios I have encountered. Please feel free to add to this or post any questions.
Comments
Thank U for this guide!
Thank U for this guide!
In the Pear CentOS Install #2 non root commands i think there's an error in wget as it prints the download on screen.
I think it should be simply like this:
wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
nessunluogo
Thank you!
Easy follow and I am good to go :)
First, I installed Putty on my Host and the missing instructions to install Drush, I found through your post.
Thank you very much for sharing.
a big thanks~!
this is very useful for me ,i am trying to install drush in centos
Centos 5 Console_Table error
Using the instructions from "Pear CentOS Install #1" point 4.
On Centos 5 you may receive this error after installing drush and then trying to run it as a normal user: "Drush needs to download a library...Console_Table..." and a permission error. This is due to Console_Table missing. This is resolved by:
pear install Console_Table
I have followed the above
I have followed the above steps on by Unix machine.
Now when I am usnig it, it is saying
Same error here.
Same error here.
Running
sudo drush --version
(just once) fixed my problem. HTH--
Fedora release 21 (Twenty One)
Hi i have this error
Hi i have this error
but i correct this issue with this answer
and uncomment this line
but in red hat distributions this is in other place for example in /usr/share/pear/drush/lib/
try to find the location and working
Things went ok but then drush --version said not so fast.
started the lamp server
lamp start
sudo /opt/lampp/lampp start
Starting XAMPP for Linux 5.6.8-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
I had to do do the following this after
(cd ~; su -p root)
so i was root AND so then the paths are right to find PEAR
pear channel-discover pear.drush.org 2>&1
Adding Channel "pear.drush.org" succeeded
Discovery of channel "pear.drush.org" succeeded
and I do have this autoload.php on my machine anyway.
sudo find / -name autoload.php
/home/lh/.composer/vendor/autoload.php
/home/lh/.composer/vendor/d11wtq/boris/lib/autoload.php
The peer install seemed to go ok
cat go.ksh
#! /usr/bin/ksh
ksh -c "(pear install drush/drush 2>&1)"|tee go.log
cat go.log|xfold -ns
001 downloading drush-6.2.0.0.tgz ...
002 Starting to download drush-6.2.0.0.tgz (505,989 bytes)
003 .........done: 505,989 bytes
004 install ok: channel://pear.drush.org/drush-6.2.0.0
but
which drush
/usr/bin/drush
sudo drush --version
drush --version 2>&1
Unable to load autoload.php.
Drush now requires Composer in order to install its
dependencies and autoload classes.
Please see README.md
well I do actually have composer installed
which composer
/usr/local/bin/composer
composer --version
Composer version 1.0-dev
(8e9659bd8317ad3f623c4d17940380443cf8772c) 2015-06-14 09:10:46
and a composer based install earlier failed for lots of odd reasons
like stuff like crypto missing ... Check BB's and the fix was very
complex so
so here I am giving Pear a try. Can I install another earlier version
or drush that does not use composer maybe?
There is lots detritus left over from former attempts
sudo find / -name drush
/usr/bin/drush
/usr/local/src/drush
/usr/local/src/drush/drush
/home/lh/.composer/vendor/bin/drush
/home/lh/.composer/vendor/drush
/home/lh/.composer/vendor/drush/drush
/home/lh/.composer/vendor/drush/drush/examples/drush
/home/lh/.composer/vendor/drush/drush/drush
/opt/lampp/bin/drush
/opt/lampp/apps/drupal/htdocs/sites/all/modules/views/drush
/opt/lampp/apps/drupal/htdocs/sites/all/modules/ctools/drush
/opt/lampp/apps/drupal/htdocs/sites/all/modules/apachesolr/drush
/opt/lampp/apps/drupal/drush
/opt/lampp/apps/drupal/drush/drush
/opt/lampp/lib/php/drush
Hello,
Hello,
@jomarocas Try this:
@lawrencecharleshickey try using the Installing on shared hosting instructions. Not 100% sure how to do things on XAMPP. We make a better environment anyway: http://www.kalamuna.com/products/kalabox/ if you want to change it up.
John Ouellet
Sales Engineering Manager
https://thinktandem.io/
thanks for trying to help. Maybe I need composer to uninstall it
1) pear uninstall drush/drush 2>&1
produces
001 uninstall ok: channel://pear.drush.org/drush-6.2.0.0
2) pear channel-discover pear.drush.org 2>&1
produces
001 Channel "pear.drush.org" is already initialized
3) pear install drush/drush-5.9.0 2>&1
produces
001 downloading drush-5.9.0.tgz ...
002 Starting to download drush-5.9.0.tgz (412,080 bytes)
003 .....................................
...........................................
....done: 412,080 bytes
004 install ok: channel://pear.drush.org/drush-5.9.0
which drush
/usr/bin/drush
drush --version 2>&1
1 Unable to load autoload.php. Drush now requires
2 Composer in order to install its dependencies
3 and autoload classes. Please see README.md
stat /usr/bin/drush
1 File: `/usr/bin/drush' -> `/usr/local/src/drush/drush'
2 Size: 26 Blocks: 0 IO Block: 4096 symbolic link
3 Device: 801h/2049d Inode: 32645980 Links: 1
4 Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
5 Access: 2015-06-24 20:29:40.699724066 -0400
6 Modify: 2015-06-20 21:42:36.662675924 -0400
7 Change: 2015-06-20 21:42:36.662675924 -0400
8 Birth: -
stator -m /usr/local/src/drush/drush
2015 06 20 214118 /usr/local/src/drush/drush
date
Wed Jun 24 20:36:26 EDT 2015
This is not a new one.
THis is an old one from june 20
date Wed Jun 24 20:38:42 EDT 2015
today is june 24.
This "pear uninstall drush/drush 2>&1
is NOT removing the old drush
ok I used composer to install- sort of - drupal
Ok I thought maybe I could use compser to get rid of it
consulting
http://drupal.stackexchange.com/questions/135599/how-to-uninstall-drush-...
here is the advice
Edit your composer.json file, e.g.
vim ~/.composer/composer.json
and remove line containing drush. Save the file.
Update Composer PHP packages by:
composer global update
It will remove a globally installed drush.
OK
lets try that advice
---------------------------
whoami
root
find / -name composer.json
001 /usr/local/src/drush/composer.json
002 /home/lh/.composer/composer.json
003 /home/lh/.composer/vendor/pear/console_table/composer.json
004 /home/lh/.composer/vendor/symfony/var-dumper/composer.json
005 /home/lh/.composer/vendor/symfony/yaml/composer.json
006 /home/lh/.composer/vendor/d11wtq/boris/composer.json
007 /home/lh/.composer/vendor/drush/drush/composer.json
008 /opt/lampp/apps/drupal/drush/lib/Yaml-2.2.1/composer.json
009 /opt/lampp/apps/drupal/drush/composer.json
010 /opt/lampp/phpmyadmin/composer.json
I have lots and lots of composer.json files.
Lets see how many contain any mention of drush
find / -name composer.json -exec grep -n drush {} /dev/null \;
1 ----------------
2 001 /usr/local/src/drush/composer.json:2: "name": "drush/drush",
3 002 /usr/local/src/drush/composer.json:4: "homepage": "http://www.drush.org",
4 003 /usr/local/src/drush/composer.json:18: "forum": "http://drupal.stackexchange.
5 com/questions/tagged/drush",
6 004 /usr/local/src/drush/composer.json:19: "irc": "irc://irc.freenode.org/drush"
7 005 /usr/local/src/drush/composer.json:22: "drush",
8 006 /usr/local/src/drush/composer.json:23: "drush.php",
9 007 /usr/local/src/drush/composer.json:24: "drush.bat",
10 008 /usr/local/src/drush/composer.json:25: "drush.complete.sh"
11 ---------------
12
13 ---------------
14 009 /home/lh/.composer/composer.json:3: "drush/drush": "dev-master"
15 ---------------
16
17 ---------------
18 010 /home/lh/.composer/vendor/drush/drush/composer.json:2: "name": "drush/drush",
19 011 /home/lh/.composer/vendor/drush/drush/composer.json:4: "homepage": "http://www.
20 drush.org",
21 012 /home/lh/.composer/vendor/drush/drush/composer.json:19: "forum": "http://drup
22 al.stackexchange.com/questions/tagged/drush",
23 013 /home/lh/.composer/vendor/drush/drush/composer.json:20: "irc": "irc://irc.fre
24 enode.org/drush"
25 014 /home/lh/.composer/vendor/drush/drush/composer.json:23: "drush",
26 015 /home/lh/.composer/vendor/drush/drush/composer.json:24: "drush.php",
27 016 /home/lh/.composer/vendor/drush/drush/composer.json:25: "drush.bat",
28 017 /home/lh/.composer/vendor/drush/drush/composer.json:26: "drush.complete.sh"
29 018 /home/lh/.composer/vendor/drush/drush/composer.json:40: "drush/config-extra
30 ": "Provides configuration workflow commands, such as config-merge."
31 ---------------
32
33 ---------------
34 019 /opt/lampp/apps/drupal/drush/composer.json:2: "name": "drush/drush",
35 020 /opt/lampp/apps/drupal/drush/composer.json:4: "homepage": "http://www.drush.org
36 ",
37 021 /opt/lampp/apps/drupal/drush/composer.json:16: "forum": "http://drupal.stacke
38 xchange.com/questions/tagged/drush",
39 022 /opt/lampp/apps/drupal/drush/composer.json:17: "irc": "irc://irc.freenode.org
40 /drush"
41 023 /opt/lampp/apps/drupal/drush/composer.json:20: "drush",
42 024 /opt/lampp/apps/drupal/drush/composer.json:21: "drush.php",
43 025 /opt/lampp/apps/drupal/drush/composer.json:22: "drush.bat",
44 026 /opt/lampp/apps/drupal/drush/composer.json:23: "drush.complete.sh"
45 ---------------
four of the composer.json files have drush stuff in them.
In the face of such a mess, what can I do?
I also has this issue. But I
I also has this issue. But I can not found the drush.ini file, only I have found example.drush.ini. Can you please tell me the full path of drush.ini file?
Sandip Choudhury
http://hostingultraso.com
used this commands godaddy
how install drush in bluehost or shared bluehost
Almost worked
These instructions worked for me on CentOS (I downloaded Drush 8 instead). The last command (
drush
) didn't work because, as the notice at the top of the page says, you need to use Composer these days. You install Composer thencd
into your drush directory and runcomposer install
.There are some ideas of how to install Composer on a shared server on this thread. I don't know if any of them work because I got root access to the server in my case.