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
Initially create a file
config.multisite.yaml within the
.ddev directory, with additional hostnames and post hooks.
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.
Next, restart the ddev with the command
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>