Drupal Multisite Setup on a XAMPP with Localhost

Multisite Setup on a XAMPP with Local Host

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

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 drupal8multisite, will be reachable at drupal8multisite.com, and will be installed at /xampp/htdocs/drupal8multisite

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

Step 1: Installing XAMPP
Download the file to your local drive and simply install using the defaults

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    drupal8multisite.com
127.0.0.1    drupal8multisite.com.site1
127.0.0.1    drupal8multisite.com.site2
127.0.0.1    drupal8multisite.com.site3
127.0.0.1    drupal8multisite.com.site4

Note: They all point to the same local host address

Create your virtual hosts in the httpd-vhosts.conf -(e.g., located here: C:\xampp\apache\conf\extra\httpd-vhosts.conf)

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

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

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

#
<VirtualHost *:80>
    ServerName drupal8multisite.com.site3
    DocumentRoot "C:/xampp/htdocs/drupal8/web"
    <Directory  "C:/xampp/htdocs/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
Create a database for the multisite root site
Download and extract a copy of Drupal 8 into that web directory.
Install Drupal by visiting drupal8multisite.com and following the install UI.

Step 3: Setup your sites folder
Navigate to your sites folder (e.g., C:/xampp/htdocs/drupal8/web/sites)
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.

Create the subfolders for each of your sites - name them with the base URL you defined in step 1.2 (e.g., drupal8multisite.com.site1)

Each sub-site should have these folders

  • files
  • modules
  • themes

Copy settings.php file into the folder and update database connection and private files path
Copy services.yml file into the folder
Done - you can go to the sites!

Refer: https://www.drupal.org/docs/8/multisite/drupal-8-multisite-on-a-wamp-stack-local-host

Tags

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
13 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.