Drupal can be configured to allow multiple sites to be served from a single codebase.
This demo shows how to implement a Drupal multi-site project on Platform.sh.
You can set up each site with a separate subdomain on Platform.sh quickly with only a few modifications to our Drupal 8 template.
First, you can modify your
routes.yaml file to assign a unique subdomain for each site.
We're going to use the subdomains
second for the two sites, and reuse those
names throughout all of the following configuration steps. Notice how each subdomain is pointing at the same application,
app, as its upstream route.
Next, you can give each site its own
config/sync subdirectory, as well as settings in the
sites subdirectory. To start off, each site's settings can be identical to those in
default, but you can always customize them when you need to.
second has its own database and endpoint, so we will
give each of them a corresponding relationship in our
Each of those databases is defined for the same MariaDB instance in the project's
Notice that each database's relationship uses the service name
db but then includes the unique
endpoint defined for each of the two sites.
Once we deploy the application, we can see that each subdomain contains its own separate Drupal 8 installation.
We kept the subsite and endpoint names identical so that we could include some glue code that gets each installation to talk to the right database. While we did not cover that code in this demo, it's relatively simple, so be sure to check out our Drupal 8 Multisite template on GitHub for all of the details.