Project

General

Profile

Installing Drush for working with Drupal 6-8 and Backdrop » History » Revision 58

Revision 57 (Jack Aponte, 01/20/2022 07:01 PM) → Revision 58/62 (Jack Aponte, 01/20/2022 07:04 PM)

{{lastupdated_at}} by {{lastupdated_by}} 

 {{>toc}} 

 h1. Installing Drush for working with Drupal 6-8 and Backdrop 

 An important note: we no longer need to install any version of Drush except Drush 8, since that now supports "Drupal 6, 7, <8.3 _and_ Backdrop.":http://docs.drush.org/en/master/install/#drupal-compatibility 

 h2. Installing and updating Drush 8 for all users 

 I've followed the "Install a global Drush via Composer" instructions under in the "Drush 8 alternative installation documentation.":http://docs.drush.org/en/8.x/install-alternative/ 

 Since running @composer install@ as root is a "security risk":https://getcomposer.org/doc/faqs/how-to-install-untrusted-packages-safely.md, you can use commands like these to install Drush in your home directory first, then move it to a globally-accessible location using @sudo@: 

 <pre> 
 cd ~ 
 COMPOSER_HOME=$HOME/drush COMPOSER_VENDOR_DIR=$HOME/drush/8 composer require drush/drush:8.4.10 
 cd ~/drush/8/drush/drush 
 composer install 
 cd ~ 
 sudo mv ~/drush /opt/ 
 sudo chown -R root: /opt/drush 
 sudo ln -s /opt/drush/8/drush/drush/drush /usr/local/bin/drush 
 </pre> 

 Replace "8.4.10" (last updated in this documentation on 01/20/2022) with the tag of the most recent stable 8.x release (see https://github.com/drush-ops/drush/releases) 

 If you _must_ run @composer install@ and the other commands above as root, e.g. if that's the only user we have access to on the server, you can do so by changing the @COMPOSER_HOME@ path to @/opt/drush@ and @COMPOSER_VENDOR_DIR@ to @/opt/drush/8@ and adjusting the other commands above accordingly. 

 


 Use the same commands with a new version number to update Drush as needed, adding @sudo rm -rf /opt/drush@ before the @sudo mv ~/drush /opt/@ line above. needed. 

 h2. Install and update Drush Backdrop commands 

 In order for Drush to work with Backdrop, you must install the "Drush Backdrop commands":https://github.com/backdrop-contrib/drush within the Drush 8 installation itself. 

 Assuming that Drush 8 is installed in @/opt/drush/8/drush/drush@, as specified above: 

 <pre> 
 sudo git clone https://github.com/backdrop-contrib/drush.git /opt/drush/8/drush/drush/commands/backdrop 
 </pre> 

 To update Drush Backdrop commands installed like this: 

 <pre> 
 cd /opt/drush/8/drush/drush/commands/backdrop 
 sudo git pull origin 
 </pre> 

 h2. Install Drush on May First Movement Technology and other shared hosting environments 

 Primarily drawn from "this MF ticket;":https://support.mayfirst.org/ticket/11691#comment:3 thanks Ivan! 

 First, install Composer following "these instructions":https://getcomposer.org/download/. 

 Then to install Drush: 

 <pre> 
 echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc 
 source ~/.bashrc 
 cd ~/<organization.org>/bin 
 composer global require drush/drush:8.4.10 
 which drush 
 </pre> 

 Note that sometimes @cgi-bin@ is present on MF/PL sites instead of @bin@. 

 If using Drush aliases, you may need to specify the new Drush installation in the shared @aliases.drushrc.php@ file or a local aliases file. Here's an example: 

 <pre> 
 $aliases['organization'] = array( 
   'remote-host' => 'organization.org', 
   'remote-user' => 'organization', 
   'root' => '/home/members/organization/sites/organization.org/web', 
   'uri' => 'organization.org', 
   'path-aliases' => array( 
     '%drush-script' => '/home/members/organization/sites/organization.org/users/organization/.composer/vendor/bin/drush', 
     '%dump-dir' => '~/drush-backups', 
     '%files' => '/home/members/organization/sites/organization.org/web/sites/default/files',), 
 ); 
 </pre>
Go to top