Skip to content

Latest commit

 

History

History
80 lines (62 loc) · 4.04 KB

install-alternative.md

File metadata and controls

80 lines (62 loc) · 4.04 KB

Install a global Drush via Composer

To install Drush globally for a single user follow the instructions below, or watch a video by Drupalize.me.

  1. Install Composer globally.
  2. Add composer's bin directory to the system path by placing export PATH="$HOME/.composer/vendor/bin:$PATH" into your ~/.bash_profile (Mac OS users) or into your ~/.bashrc (Linux users).
  3. Install latest stable Drush: composer global require drush/drush.
  4. Verify that Drush works: drush status

Notes

  • Update to latest release (per your specification in ~/.composer/composer.json): composer global update

  • Install a specific version of Drush:

      # Install a specific version of Drush, e.g. Drush 7.1.0
      composer global require drush/drush:7.1.0
    
      # Install master branch as a git clone. Great for contributing back to Drush project.
      composer global require drush/drush:dev-master --prefer-source
    
  • Documentation for composer's require command.

  • Uninstall with : composer global remove drush/drush

Install Drush for all users via Composer

If you need Drush installed for all users on a system using Composer, install Composer globally then follow the steps below.

Important: Run these shell commands as a privileged user with write access to /opt and /usr/local/bin or prefix with sudo.

# Create and/or navigate to a path for the single Composer Drush install.
mkdir --parents /opt/drush-8.x
cd /opt/drush-8.x
# Initialise a new Composer project that requires Drush.
composer init --require=drush/drush:8.* -n
# Configure the path Composer should use for the Drush vendor binaries.
composer config bin-dir /usr/local/bin
# Install Drush. 
composer install

Getting Updates

Use composer to update Drush just as you would with any other composer managed project. The vendor binaries will be updated for all users.

# Navigate to the Drush install path.
cd /opt/drush-8.x
# Run composer update
composer update

Major Version Upgrade

If upgrading to a new major version the steps are the same, with one addition:

# Remove the existing symlinks to Drush vendor binaries. 
find /usr/local/bin -lname '/opt/drush*' -exec unlink \{\} \;
# Follow the steps shown above, starting with creation of a new path.
mkdir --parents /opt/drush-9.x
cd /opt/drush-9.x

Important: At the time of writing composer will warn you if it cannot create vendor binaries due to a name conflict with an existing file.

Windows

Drush on Windows is experimental, since Drush's test suite is not running there (help wanted).

  • Acquia Dev Desktop is excellent, and includes Drush. See the terminal icon after setting up a web site.
  • Or consider running Linux/OSX via Virtualbox. Drupal VM and Vlad are popular.
  • These Windows packages include Drush and its dependencies (including MSys).
  • Or install LAMP on your own, and run Drush via Git's shell, in order to insure that all depedencies are available.
  • When creating site aliases for Windows remote machines, pay particular attention to information presented in the example.aliases.drushrc.php file, especially when setting values for 'remote-host' and 'os', as these are very important when running drush rsync and drush sql-sync commands.