Get a local instance of Drupal up and running fast with DDEV
A quickstart guide to getting a brand new instance of Drupal running on your Mac, with minimal fuss and stress (hopefully, anyway).
This is the quickest way I’ve found to get a local instance of Drupal up and running on macOS. Deployment — a whole other subject — isn’t covered in this post.
Requirements permalink
If you have not already done so, install the following tools:
- Docker Desktop
- Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Composer:
brew install composer
- Node/npm:
brew install node
- DDEV:
brew tap drud/ddev && brew install ddev
- mkcert:
mkcert -install
Installation permalink
I initially followed this Digital Ocean guide and distilled the key steps into the below sequence. (The Digital Ocean tutorial also covers Linux.)
mkdir <project-name>
cd <project-name>
ddev config --project-type=drupal9 --docroot=web --create-docroot
ddev start
ddev composer create "drupal/recommended-project"
ddev composer require "drush/drush"
- If you get a PHP version error running this command:
- Update
php_version
in.ddev/config.yaml
ddev restart
- Run step 6 again
- Update
- If you get a PHP version error running this command:
ddev exec drush site:install --account-name=admin --account-pass=admin
(or replaceadmin
with a more secure username and password)- Alternatively, if you have an existing website, import a database dump of it, eg
ddev import-db --src=private/backups/db.sql
- Alternatively, if you have an existing website, import a database dump of it, eg
- Modify the path for the config files in the DDEV settings file:
sed -i '' "s|^# \\\$settings\['config_sync_directory'\].*|\$settings['config_sync_directory'] = '../config/sync';|" web/sites/default/settings.php
ddev launch
The new Drupal site, with the URL https://<project-name>.ddev.site/
, should now open in your browser.
That’s it permalink
I also tend to install Bootstrap5 as a starter theme: composer require 'drupal/bootstrap5:^3.0'
. And these modules:
- Simple XML sitemap:
composer require 'drupal/simple_sitemap'
thenddev drush pm:enable simple_sitemap
- Admin Toolbar:
composer require 'drupal/admin_toolbar'
thenddev drush pm:enable admin_toolbar
At this point you might commit the code to a git repo, then get on with developing your site.
If you have any corrections or optimisations, please comment below.