Drush 9.x Install Composer to your LOCAL user directory
cd ~ mkdir .composer curl -sS https://getcomposer.org/installer | 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:
https://github.com/drush-ops/drush/releases
cd /LOCATION/OF/DRUPAL composer require drush/drush
And we done...
Drush 9.x GLOBAL INSTALL
cd ~ mkdir bin chmod +x bin cd bin wget https://github.com/drush-ops/drush/releases/download/[VERSION]/drush.phar 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
PREVIOUS METHOD:
cd ~ git clone https://github.com/drush-ops/drush.git drush # or to install another version; example 8.x which is PHP 5.5 compatible # git clone -b 8.x https://github.com/drush-ops/drush.git cd ~/drush composer install
To update drush after install:
cd ~/drush git pull https://github.com/drush-ops/drush.git master composer update
Drush 8.x GLOBAL INSTALL
Help docs: https://docs.drush.org/en/8.x/install/
Get the latest (or whatever) version here:
https://github.com/drush-ops/drush/releases
mkdir /usr/local/src/drush cd /usr/local/src/drush # wget -O drush.phar https://github.com/drush-ops/drush/releases/download/[VERSION]/drush.phar
wget -O drush.phar https://github.com/drush-ops/drush/releases/download/8.1.16/drush.phar chmod +x drush.phar cp -Rf drush.phar /usr/local/bin/drush cd /LOCATION/OF/DRUPAL
TROUBLESHOOTING
If you get the following errors:
PHP extension pcntl is missing from your system
PHP extension readline is missing from your system
Do the following:
yum install readline-devel
You can do this via rebuild PHP or install the extensions seperately
Option 1: Rebuild PHP with custombuild
cd /usr/local/directadmin/custombuild/
The default custombuild 2.0 selection for PHP 5.5 and 5.6 is the following:
cp -p configure/ap2/configure.php55 custom/ap2/configure.php55 cp -p configure/ap2/configure.php56 custom/ap2/configure.php56 vi custom/ap2/configure.php55 vi custom/ap2/configure.php56
Add the following and save the file
--enable-pcntl \ --with-readline \
Now rebuild php
./build apache && ./build php -n && ./build rewrite_confs
Option 2: Install extensions individually
cd /usr/local/src
Download and extract the php version you have installed:
wget http://php.net/get/php-5.5.25.tar.gz/from/this/mirror -O php-5.5.25.tar.gz cd /usr/local/src/php-5.5.25/ext/pcntl/ phpize && ./configure && make install cd /usr/local/src/php-5.5.25/ext/readline/ phpize && ./configure && make install
Add the following to your php.ini and save the file
vi /usr/local/lib/php.ini
; PCNTL extension=pcntl.so ; readline extension=readline.so
Restart apache
service httpd restart
For Godaddy hosting, do the following (DEPRECATED: use local instructions above):
*** THIS MAY BE OUTDATED *** Use above local install instructions instead
cd ~ git clone https://github.com/drush-ops/drush.git drush curl -sS https://getcomposer.org/installer | php mv composer.phar composer cd drush composer install
To update an existing drush git installation
cd ~/drush git pull https://github.com/drush-ops/drush.git 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 fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH
Now let's test it.
drush
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.
Troubeshooting
"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 README.md
If you get this error message :
git-remote-https: /usr/local/lib/libz.so.1: no version information available (required by git-remote-https) git: /usr/local/lib/libz.so.1: 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) zlib=yes new_zlib=yes new_xml2=yes
Then do the following:
./build zlib; ./build libxml2; ./build php n
And that should fix it.