Skip to main content

Spinning up a local Drupal environment on Mac OS

Filed on February 2, 2025

Oftentimes I discover that all the steps I need to do something on my local machine are split across various how-to guides or documentation pages. So I thought I'd collect them all in one place.

The basics

Whether I get a new machine or re-install system software from scratch for whatever reason, I start off with installing Xcode and its Command Line Tools:

xcode-select --install

and Homebrew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

I used to go the old-school route and create my own LAMP stack. Hat tip to Chris Mallinson for this guide, as well as to Andy Miller for these guides on Grav. But I guess you can teach an old dog new tricks, and I've started using a Docker setup, which is much, much quicker and less prone to errors from hobbyists like me.

I prefer to use Orbstack as a Docker Desktop alternative. Once that's installed, I install DDEV.

brew install ddev/ddev/ddev
mkcert -install

My particulars

I use Google Cloud to host my website, with code hosted on Github. So I install both the Google Cloud SDK and the Github CLI. Google recommends downloading an installer but I just go with Homebrew:

brew install google-cloud-sdk

Same with Github CLI:

brew install gh

I clone my repo into a my ~/Sites folder and then get DDEV up and running by moving into the repo directory and doing the following, as outlined in this Drupal doc:

ddev config --project-type drupal

Then I start the project, get Composer updated and install Drush:

ddev start
ddev composer install
ddev composer require drush/drush

Bring in the existing site

I'm not starting from scratch, so I'll need to bring the most recent database dump to my local.

What I do first is SSH into my Google Compute Engine VM and navigate to the webroot. I then get a database dump and save it to my user older.

vendor/bin/drush sql-dump > /home/$USER/$FILENAME.sql

From there, I exit the remote and use the Google Cloud CLI to grab that file onto my local.

gcloud compute scp $VM:/home/$USER/$FILENAME.sql ~/Sites

Then I make sure I'm in the project root in my local and run this DDEV command to import the database file:

ddev import-db --file=~/Sites/$FILENAME.sql

From there, it's just standard launch command to get things going.

ddev launch

To make things easier, I like to set a new admin password to make logging in a bit easier:

ddev drush user:password admin "admin"

Happy coding!