Drupal 8 Multisite on a WAMP stack - Local Host

Last updated on
7 September 2018

This page has not yet been reviewed by Multisite Drupal maintainer(s) and added to the menu.

The multisite behavior is a great way to explore the functionality and prototyping of sites and building out a content management ecosystem.  With drupal 8 and the many installation instructions out there - wanted to prepare a basic guide on how to get this to work for those looking to simply do it locally on their windows machines.  We'll leverage the LAMP Multisite instructions for the sake of alignment.

Overview of the process:

  1. Install a WAMP on your local machine.  Followed recommendations to not install in program files as there is some firewall problems. (e.g., c:\wamp64)

  2. Install a Drupal 8 instance that will act as the root site for our multisite instance. In our example, the root site will be called d8multisite, will be reachable at d8multisite.com, and will be installed at /var/www/d8multisite

  3. Set up a sites within the multisite called site1..5 which is reachable at d8multisite.com.site1..5

Step 1: Installing WAMP Stack

  1. Download the file to your local drive and simply install using the defaults

  2. Locate your hosts files - these can be tucked in a variety of locations (C:\Windows\System32\drivers\hosts).  This will be important to keep a backup and you'll have to add the name of your server to this file. 
    For example:


     

    127.0.0.1    localhost
    127.0.0.1    d8multisite.com
    127.0.0.1    d8multisite.com.site1
    127.0.0.1    d8multisite.com.site2
    127.0.0.1    d8multisite.com.site3
    127.0.0.1    d8multisite.com.site4
    127.0.0.1    d8multisite.com.site5


    Note: They all point to the same local host address

  3. Create your virtual hosts in the httpd-vhosts.conf -(e.g., located here: C:\wamp64\bin\apache\apache2.4.33\conf\extra\httpd-vhosts.conf)
     


    #
    <VirtualHost *:80>
        ServerName d8multisite.com 
        DocumentRoot "C:/wamp64/www/drupal8/web"
        <Directory  "C:/wamp64/www/drupal8/web/">
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require local
        </Directory>
    </VirtualHost>

    #
    <VirtualHost *:80>
        ServerName d8multisite.com.site1
        DocumentRoot "C:/wamp64/www/drupal8/web"
        <Directory  "C:/wamp64/www/drupal8/web/">
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require local
        </Directory>
    </VirtualHost>

    #
    <VirtualHost *:80>
        ServerName d8multisite.com.site2
        DocumentRoot "C:/wamp64/www/drupal8/web"
        <Directory  "C:/wamp64/www/drupal8/web/">
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require local
        </Directory>
    </VirtualHost>

    #
    <VirtualHost *:80>
        ServerName d8multisite.com.site3
        DocumentRoot "C:/wamp64/www/drupal8/web"
        <Directory  "C:/wamp64/www/drupal8/web/">
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require local
        </Directory>
    </VirtualHost>
     


    Note: You would simply keep repeating the VM's for each site you have - pattern is the same.

Step 2: Installing Drupal - Main Site

  1. Create a database for the multisite root site
  2. Download and extract a copy of Drupal 8 into that web directory.
  3. Install Drupal by visiting d8multisite.com and following the install UI.

Step 3: Setup your sites folder

  1. Navigate to your sites folder (e.g., C:/wamp64/www/drupal8/web/sites)
  2. Copy example.sites.php and rename to sites.php  If your naming convention does not require alias - that's all you need to do.  No sym links - none of the extra aspects.
  3. Create the subfolders for each of your sites - name them with the base URL you defined in step 1.2 (e.g., d8multisite.com.site1)
    1. Each sub-site should have these folders
      1. files
      2. modules
      3. themes
    2. Copy settings.php file into the folder and update database connection and private files path
    3. Copy services.yml file into the folder

Done - you can go to the sites!

Help improve this page

Page status: No known problems

You can: