Skip to main content

How to Configure Virtual Host on Windows 10 and Drupal 8 Multisite on localhost

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. 

Comments

  1. Here, Please do entry of site1.localhost and site2.localhost also in httpd-vhosts.conf


    DocumentRoot "C:/xampp/htdocs/d8multisite."
    ServerName site1.localhost





    DocumentRoot "C:/xampp/htdocs/d8multisite."
    ServerName site2.localhost


    ReplyDelete

Post a Comment

Popular posts from this blog

How to configure memcache with drupal 8 on ubuntu for reduce page load?

Memcache is an in-memory (RAM). It store data in Key-Value Format. Memcached server automatically stores all the content (data) in allocated RAM on the server. After configure memcache, it increase Drupal Site performance by moving standard caches out of the database. Drupal does not come with memcache by default if we want to install it then we have to install it on server. There are many steps that how to install memcache on the server and how to configure it with drupal 8 for reducing the load on the database with every page request. Step1 :- Open terminal of your machine and run following commands :- a. sudo apt-get update b. sudo apt install memcached c. sudo apt install php-memcached Step2 :- Check that Memcache daemon is working by using the following command : a. "ps aus | grep memcached" Step3 :- Also, check Memcache extension is configured in PHP. For that you have create a file phpinfo.php then write below code. <?php phpinfo(); ?> or sudo vi /var/www/html...

How deploy your angular project on GitHub Pages

Step 1:- Create Repository on github Note :- Open terminal and goto your project direcoty then run following command which you got after created repository. Step 2:- git init Step 3:- git add . Step 4:- git commit -m "first commit" Step 5:- git branch -M main Step 6:- git remote add origin https://github.com/rahuldrupal5788/DevR9angular.git Step 7:- git push -u origin main Step 8:- We need to build our code in production mode for that we will create deployment files that will be deployed on GitHub Pages. By default, this deployment code is generated in the /dist/<ProdectName> folder under the angular project folder, but we need to generate this in the "docs" folder under the angular project folder. So, we need to make a small change in the angular.json file and change the outputpath value to "docs/". Step 9:- Run the following command with the baseHref  option in the git bash window to generate deployment files in the docs folder. ng build --prod --b...

What is Docker? How to create Dockerfile, Volumes? How to manage container with Port Mapping?

What is Docker? Docker is an open source centerlized Platform designed to Create, Deploy and run applications. Docker use container on the host OS to run applications. It allows application to use the same linux Kernal as a System on the host computer, rather than creating a whole virtual OS. We can install docker on any OS but Docker engine run natively on linux distribution. Docker written in 'go' language. Docker is a tool that perform OS level virtualization, also known as Containerization. Before Docker, many users faces the problem that a particular Code is running in  the developer's system but not in the User's System. Docker was first Release in March 2013. It is developed by Soloman Hykes and Sebastion Pahl. Docker is a set of Platform as a service that uses OS level Virtualization whereas VMware uses Hardware level Virtualization. We can say that Docker is a tools which create the VM. Advantages of Docker :- There are following advantage of Docker : No pre-a...