Setting Up a Drupal 9 Multisite Locally with DDEV: Hosted on Acquia with Acquia Pipelines
Tags: drupal, acquia
Published: 2023-03-13 22:44:10

---
title: Setting Up a Drupal 9 Multisite Locally with DDEV: Hosted on Acquia with Acquia Pipelines
published: true
date: 2023-03-13 00:40:00 UTC
tags: Drupal,Acquia
canonical_url: https://davidloor.com/2023/03/12/setting-up-drupal-9-multisite-locally-ddev-hosted-acquia-with-acquia-pipelines/
---

![Drupal 10](https://i0.wp.com/davidloor.com/wp-content/uploads/2022/12/cu2nf0jz5pi.jpg?resize=800%2C539&ssl=1)

In my current job, the team that I lead is providing support to three websites of a large private organization. The three websites are hosted on Acquia. The websites are part of a multisite setup and the source code is managed using the [Acquia Pipelines](https://docs.acquia.com/pipelines/) service.

In a nutshell, [Acquia Pipelines](https://docs.acquia.com/pipelines/) is a continuous integration and deployment service provided by Acquia, a cloud-based platform that provides enterprise-level hosting, support, and management for Drupal websites.

## What is DDEV?

DDEV is a command-line tool that helps developers set up local development environments quickly and easily. It is designed to simplify the process of setting up a local web server, managing dependencies, and configuring development environments. If this is the first time that you are trying to work with DDEV, please make sure that you check this [post](https://dev.to/davo20019/how-to-setup-a-wordpress-or-drupal-site-locally-with-ddev-4035-temp-slug-181423) to get started with DDEV.

## What is a Drupal multisite?

Drupal multisite is a feature that allows multiple websites to be managed using a single Drupal codebase and database. In a Drupal multisite setup, multiple websites share a single Drupal installation, which can reduce maintenance time and costs.

Each website in a Drupal multisite configuration has its own unique domain or subdomain and can have its own theme, modules, content, and configurations. However, they share the same core codebase and database.

Drupal multisite is useful when you need to manage multiple websites that share a similar codebase, theme, or functionality, such as a network of related websites, or multiple language versions of a website. It can simplify website maintenance, reduce costs, and improve consistency across websites.

## The recipe to setup the local multisite 

1. You need to set up the project using DDEV. Check this [post](https://dev.to/davo20019/how-to-setup-a-wordpress-or-drupal-site-locally-with-ddev-4035-temp-slug-181423) out to get started.
  - The docroot location from where the site is served should be **web/docroot.** You will be asked a question about the docroot location when running the command `ddev config`
2. In the .ddev folder, create a file name **config.multisite.yaml**
3. The file **config.multisite.yaml** should have the following content:

```
additional_hostnames:
  - site1
  - site2
  - site3
```

1. Update the sites.php file to add the three local domains and their corresponding folders.

The sites.php file is a configuration file that allows you to map domain names or URLs to specific Drupal site directories.

```
$sites['site1.ddev.site'] = 'site1_directory';
$sites['site2.ddev.site'] = 'site2_directory';
$sites['site3.ddev.site'] = 'site3_directory';
```

1. Create three databases using [PHPMyAdmin](https://www.phpmyadmin.net/). If the name of the DDEV project were **mysite** , you can access phpmyadmin at https://mysite.ddev.site:8037/
2. Export database backups from acquia and import them into the corresponding databases that you created as part of step 4.
  - If the databases are big, you can use a ddev command to import them: `ddev import-db --target-db=DATABASE_NAME --src=.tarballs/DB-BACKUP_FILE.sql.gz`
3. In the directory of each file, you need to add this ddev [file](https://github.com/davo20019/ddev-local-multisite/blob/main/settings.ddev.php).
4. The settings.php file of each site needs to be updated to include the code from [this file](https://github.com/davo20019/ddev-local-multisite/blob/main/settings.php).
5. Run `ddev ssh` and after that `composer install`
  - the `ddev ssh` command allows you to access the command line interface (CLI) of a running ddev web container, so you can run composer, drush and other commands from inside the web container.