RSSAmplifier

jamieonkeys · Jun 8, 2023

Get a local instance of Drupal up and running fast with DDEV

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

This is the quickest way I’ve found to get a local instance of Drupal up and running on macOS. (Deploying to a remote server isn’t covered in this post.) Requirements 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 :…

This is the quickest way I’ve found to get a local instance of Drupal up and running on macOS. (Deploying to a remote server isn’t covered in this post.)

Requirements

If you have not already done so, install the following tools:

  1. Docker Desktop
  2. Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Composer: brew install composer
  4. Node/npm: brew install node
  5. DDEV: brew install ddev/ddev/ddev
  6. mkcert: mkcert -install

Installation

I initially followed this Digital Ocean guide and distilled the key steps into the below sequence. (The Digital Ocean tutorial also covers Linux.)

  1. mkdir __project_name__
  2. cd __project_name__
  3. ddev config --project-type=drupal11 --docroot=web --create-docroot
  4. ddev start
  5. ddev composer create-project "drupal/recommended-project"
    • This will install the latest stable version of Drupal. To choose an older version, say v10, run ddev composer create-project "drupal/recommended-project:^10".
  6. ddev composer require "drush/drush"
    • If you get a PHP version compatibility error running this command:
      1. Update php_version in .ddev/config.yaml.
      2. ddev restart
      3. Run step 6 again.
  7. ddev exec drush site:install --account-name=admin --account-pass=admin (or replace admin with a more secure username and password.)
  8. ddev launch

Bish, bash, bosh: a new Drupal site, with the URL https://__project_name__.ddev.site/, should now open in your browser. Nae bother.

That’s it

You might like to install Bootstrap5 as a starter theme: composer require 'drupal/bootstrap5'. And these modules:

  1. Simple XML sitemap: composer require drupal/simple_sitemap && ddev drush pm:enable simple_sitemap
  2. Admin Toolbar: composer require drupal/admin_toolbar && ddev drush pm:enable admin_toolbar admin_toolbar_tools admin_toolbar_search
  3. Pathauto: composer require drupal/pathauto && ddev drush pm:enable pathauto

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.

Read on /posts/drupal-ddev-mac/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.