Drush is a command-line shell and scripting interface for Drupal. To use, you must have a shell user enabled and knowledge of the Unix shell.

Installing Drush using Composer

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

Follow the instructions at https://github.com/drush-ops/drush:

  1. Log into your server via SSH.
  2. View the creating and editing a file via SSH article for instructions on how to edit your existing .bash_profile. Add the following line if you’re using PHP 8.2. Change the number for a different version:
    export PATH=/usr/local/php82/bin:$PATH
  3. Close the file and return to your shell.
  4. Activate this file by running the following:
    [server]$ . ~/.bash_profile
  5. Navigate to your user’s directory:
    [server]$ cd ~
  6. Run the following command:
    [server]$ curl -sS https://getcomposer.org/installer | php
    All settings correct for using Composer
    Composer (version 1.8.0) successfully installed to: /home/username/composer.phar
    Use it: php composer.phar

Installing Drush

Once you have installed Composer, run the following commands to install Drush.

  1. Run the following command in your user’s directory:
    [server]$ php composer.phar require drush/drush

    If you're installing on a shared server, you may hit your user's memory limits when installing. If so, you need to contact support and ask that your user's memory limits be lifted so you can complete the installation.

    If you get a connection timed out error, you may be affected by this issue. If you have a VPS, you can use the /etc/gai.conf workaround mentioned there.

  2. Edit your .bash_profile again.

    If you're installing Drush globally (under your username for all projects), add the following to your .bash_profile:

    alias drush='~/vendor/drush/drush/drush'

    If you're installing locally (in a single project), add the following instead:

    alias drush='~/<domain>/<project>/vendor/drush/drush/drush'
  3. Make sure to update your .bash_profile again:
    [server]$ . ~/.bash_profile
  4. Run the following to initialize drush. Make sure to enter 'yes' when prompted:
    [server]$ drush init
     Modify /home/username/.bash_profile to include Drush configuration files? (yes/no) [yes]:
     > yes
    This writes a few lines to your .bash_profile and creates a .drush folder with your configuration settings.
  5. Run the following command to confirm drush is functioning:
    [server]$ drush topic

PHP Fatal error: Allowed memory size of ### bytes exhausted

If you see this error, the first thing you should do is updated your PHP memory_limit.

If you continue to see this error, you may need to adjust the following file in your site's configuration:


There are two lines in that file which set the PHP memory_limit. For example:


Raising that value should fix the memory error. 

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?