Multisite Local environment setup with DDEV and Drupal

ByKarthik Kumar D Kon26th Jan 2023, 2023-01-26T09:30:00+05:30
Read Article
Multisite Local environment setup with DDEV and Drupal

In this article we are going to see how we can set up a multisite environment with ddev on the local machine. Assuming people are aware of configuring the drupal multiple site from the drupal side of configurations.

As we all know ddev is an open source tool for running local PHP development environments in minutes, which makes developer life easier during the local environment setup process, here’s the recipe provided by ddev.

Assuming you already have ddev installed and a drupal site is up and running on local. If so check the site details by running ddev describe.

Initially create a file config.multisite.yaml within the .ddev directory, with additional hostnames and post hooks.

(reference: config.multisite.yaml)

Next, create the directories for each of the site within sites folder and create entries in sites.php (by default Drupal allows this configuration)

(reference: drupal multisite)

Next, add the settings.ddev.php files for each of the site, and add the configurations and also check if the environment is IS_DDEV_PROJECT from the env variables.

(reference: settings.ddev.php)

Next, restart the ddev with the command ddev restart.

Once the containers are up and running, then run the ddev describe and see the multi site urls.

You can use drush commands like, drush status -l <multisite-domain>, allowed by drush. Or create drush aliases and use them for each site.

(reference: drush aliases)

In case you are configuring ddev multi site for existing drupal site, you might need to import the db to the relevant databases (do it manually, in case locally you are using only on database container)

docker exec -i <db-container-name> mysql -u<user> -p<pass> <database-name> < <backup.sql>

Thanks for reading the article, for more drupal related articles read and subscribe to peoples blog articles.

We Need Your Consent
By clicking “Accept Cookies”, you agree to the storing of cookies on your device to enhance your site navigation experience.
I Accept Cookies