The following guide will highlight the virtual host configuration in window 10 and manual set up a Drupal 8 multisite.
Overview of Druapl 8 Multisite Setup :
1. First Install a Drupal 8 site that will act as the main site for our multisite.
Exp : the main site will be called d8multisite, will be reachable at localhost which setting present in virtual host, and will be installed at C:\xampp\htdocs\d8multisite
2. Set up two site within the multisite called site1 which is reachable at site1.localhost and site2 which is reachable at site2.localhost
3. Site1 and Site2 have its own modules outside of the root site.
Step 1: Install the main drupal site
1.1) Download and extract drupal 8 site setup from drupal.org into xampp directory(C:\xampp\htdocs\d8multisite)
1.2) Create a database for the main multisite, exp: d8multisite.
1.3) Configure virtual host for the main site(d8multisite).
(1.3.1) Got to following path of xampp C:/xampp/apache/conf/extra.
(1.3.2) Edit httpd-vhosts.conf with any text editor, exp: Notepad++ and delete everything in the file and paste the following code:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/d8multisite."
ServerName localhost
<Directory "C:/xampp/htdocs/d8multisite.">
</Directory>
</VirtualHost>
In the above code:
VirtualHost: Mostly web servers use port 80 which is default port. However, we can change the port to 8080, 8081, etc.
DocumentRoot: The folder path where files of a site will exist like "d8multisite".
ServerName: This is the URL for our virtual host.
Directory: This is the directory of our virtual host.
(1.3.3) Now goto following path C:\Windows\System32\drivers\etc then edit "hosts" file
Add the following line in the Host file.
127.0.0.1 localhost
After that, check http://localhost opens up in your browser.
Step 2: Configure the first site for the multisite
After main site set up, we start our first site called site1. Now follow the following steps:
2.1: Create a folder for site1 in your multisite: /d8multisite/sites/site1.localhost
2.1: Create a database for site1, ex: d8multisite_site1
2.3: Make a copy of /d8multisite/sites/example.sites.php called /d8multisite/sites/sites.php
2.4: Edit sites.php so the end of the file looks like this:
# make the root drupal site aware of site1:
$sites['site1.localhost'] = 'site1.localhost';
2.5: cp sites/default/default.settings.php sites/site1.localhost/settings.php
2.6: cp sites/default/default.services.yml sites/site1.localhost/services.yml
Step 3: Configure the second site for the multisite
After main site set up, we start our first site called site1. Now follow the following steps:
3.1: Create a folder for site1 in your multisite: /d8multisite/sites/site2.localhost
3.1: Create a database for site2, ex: d8multisite_site2
3.3: Make a copy of /d8multisite/sites/example.sites.php called /d8multisite/sites/sites.php
3.4: Edit sites.php so the end of the file looks like this:
# make the root drupal site aware of site2:
$sites['site2.localhost'] = 'site2.localhost';
3.5: cp sites/default/default.settings.php sites/site2.localhost/settings.php
3.6: cp sites/default/default.services.yml sites/site2.localhost/services.yml
Now You will be able to run the application of your choice in the virtual host.
Here, Please do entry of site1.localhost and site2.localhost also in httpd-vhosts.conf
ReplyDeleteDocumentRoot "C:/xampp/htdocs/d8multisite."
ServerName site1.localhost
DocumentRoot "C:/xampp/htdocs/d8multisite."
ServerName site2.localhost