How to install Homebrew, Composer, and Drush on Mac OSX Sierra, High Sierra, Mojave, Catalina

Installing Drush 7 on MacOSX with Composer

In order to install Drush, you should first install Composer. Composer is required for Drupal 8 and once Composer is installed, installing Drush is just a single command in your Terminal.

1. Open the Terminal app on your Mac.

2. Install Homebrew via the instructions here: https://brew.sh/

3. Install Composer globally on your Mac with this command:

brew install composer

4. If your computer doesn't have a "/usr/local/bin" directory, create that first with this command:

sudo mkdir -p /usr/local/bin

...that creates the directory; you should be prompted to enter your computer's password.

Now, when you type composer --version and press Enter, we'll see that you have Composer installed!

5. Install Drush via Composer:

composer global require drush/drush

If you get a popup to install the Xcode Developer tools, go ahead and install Xcode.

6. Add Drush to the System PATH

Now, we need to add the new Drush installation to our system path, so that we can run Drush from anywhere on our system. Add it in your user's .bash_profile file.

vi ~/.bash_profile

to edit the file

Press the i key to enter Insert mode

...next, type:

export PATH="$HOME/.composer/vendor/bin:$PATH"

Press the Escape (esc) key to switch back to command mode.

Type :wq and press Enter to save and quit the file

7. Quit the Terminal app (or, run the "source" command to load the .bash_profile file without having to restart the Terminal.)

Type

source ~/.bash_profile

and press Enter

Now if you type drush and press Enter, you'll see that Drush is installed, and working on your machine!

Wohoo!

Location

New York
108 Wooster St, New York 10012
(949) 254-0339