Installing Drush on MacOSX with Composer
- How To Install Homebrew On Macos Catalina
- Install Homebrew On Mac Catalina Update
- Install Homebrew On Mac Catalina Version
- Install Homebrew On Mac Catalina Operating System
In order to install Drush, you should first install Composer. Composer is often required for Drupal 8 and once Composer is installed, installing Drush is easy.
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:
Homebrew is a package managing tool. It’s more popular on Linux but is also used extensively on macOS. In fact, for apps that install as packages, Homebrew is the easiest way to remove them. Here’s how you can install Homebrew on macOS Catalina. In order to install Homebrew on macOS Catalina, you must have Xcode installed. Open the Terminal app on your Mac. Install Homebrew via the instructions here: 3. Install Composer globally on your Mac with this command: brew install composer. If your computer doesn’t have a “/usr/local/bin” directory, create that first with this command: sudo mkdir -p /usr/local/bin. How to install GCC 9.2 on macOS Catalina.If you need to install the Command Line Tools or Homebrew check my previous video tutorial:https://youtu.be/hOx4jwjl0Y. Installation of latest preview release via Homebrew on macOS 10.13 or higher. After you've installed Homebrew, you can install PowerShell. First, install the Cask-Versions package that lets you install alternative versions of cask packages: brew tap homebrew/cask-versions Now, you can install PowerShell: brew install -cask powershell-preview. Step 2 – Install NVM on macOS. Now, you system is ready for the installation. Update the Homebrew package list and install NVM. Brew update brew install nvm. Next, create a directory for NVM in home. Now, configure the required environment variables. Edit the following configuration file in your home directory.
brew install composer
4. If your computer doesn’t have a “/usr/local/bin” directory, create that first with this command:
How To Install Homebrew On Macos Catalina
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:
Note!: Please do not install Drush using composer global require
. See Pantheon’s article, Fixing the Composer Global command.
Instead, first install the Composer global require
command:
composer global require consolidation/cgr
6. Add the vendor/bin
from the Composer home directory to your $PATH.
(Thereafter, you may substitute cgr
for any command line tool whose installation instructions recommends the use of Composer global require. Example: cgr drush/drush
)
If you get a popup to install the Xcode Developer tools, go ahead and install Xcode.
7. Update the system $PATH:
vim ~/.bash_profile
to edit the file press the i
key to enter Insert mode
…next, copy and paste this into that file:
export PATH='$HOME/.composer/vendor/bin:$PATH'
PATH='$(composer config -g home)/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.
8. Quit the Terminal app (or, run the “source” command to load the .bash_profile file without having to restart the Terminal.)
To run the source command:
source ~/.bash_profile
9. Now you will actually install Drush:
Install latest stable Drush:
cgr drush/drush
Now if you type drush
and press Enter, you’ll see that Drush is installed, and working on your machine!
Setting Up A Database
We're going to install sqlite3 from homebrew because we can't use the built-in version with macOS Sierra without running into some troubles.
Rails ships with sqlite3 as the default database. Chances are you won't want to use it because it's stored as a simple file on disk. You'll probably want something more robust like MySQL or PostgreSQL.
There is a lot of documentation on both, so you can just pick one that seems like you'll be more comfortable with.
If you're new to Ruby on Rails or databases in general, I strongly recommend setting up PostgreSQL.
If you're coming from PHP, you may already be familiar with MySQL.
MySQL
You can install MySQL server and client from Homebrew:
Install Homebrew On Mac Catalina Update
Once this command is finished, it gives you a couple commands to run. Follow the instructions and run them:
By default the mysql user is root
with no password.
When you're finished, you can skip to the Final Steps.
Install Homebrew On Mac Catalina Version
PostgreSQL
Install Homebrew On Mac Catalina Operating System
You can install PostgreSQL server and client from Homebrew:
Once this command is finished, it gives you a couple commands to run. Follow the instructions and run them:
By default the postgresql user is your current OS X username with no password. For example, my OS X user is named chris
so I can login to postgresql with that username.