Create Virtual host for Apache on Windows 10 by Using XAMPP.

Ahmed Thaajwer
Feb 23, 2019 · 3 min read

Nowadays many developers, small businesses, and even large businesses rely on Apache to power their website on a daily basis. Apache was mainly designed to run on linux servers, but has since been ported to run on any operating system.So here we can use apache on windows operating system too.

In this blog, I am going to explain how you can setup and configure virtual hosts for drupal website with XAMPP running on windows 10.

STEP 01

First, you have to stop apache server in XAMPP control panel.

STEP 02

Then,you need to go C:\xampp\apache\conf\extra

Then,edit httpd-vhosts.conf with text editor. Here i edit with notepad++

STEP 03

After editing with text editor you will see like this.

STEP 04

Then uncomment the NameVirtualHost *:80 ,

STEP 05

Then, go to the down of the page and copy following code and paste it.

ex:

<VirtualHost *:80>
DocumentRoot “C:\xampp\htdocs\D6-Technology”
ServerName www.d6technology.lk
<Directory “C:\xampp\htdocs\D6-Technology”>
Require all granted
</Directory>
</VirtualHost>

DocumentRoot: The folder where files of a site will exist. in this case my drupal site folder name is D6-technology.

ServerName: This is the URL for our virtual host.i am using my url as www.d6technology.lk

Directory: This is the directory of our virtual host.

Then save that folder…

STEP 06

Then you need to go C:\Windows\System32\drivers\etc , It look something like this.

Then edit the hosts file in your text editor.it look like this.

At the bottom of the file just type,

127.0.0.1 [ServerName]

Ex: here i am using my server name as www.d6technology.lk

127.0.0.1 www.d6technology.lk

Then save hosts file.

Note FOR Drupal Virtual Host:

C:\xampp\htdocs\D6-Technology\sites\default go to this path in your drupal site ,check whether there is a setting.php file.if it is you have to change like this.

In the bottom of the folder you have to add this code => ‘^www\.example\.com$’, →server name

Ex: ‘^www\.d6technology\.lk$’,

Important: Then go to the Xampp control panel and start apache server.

STEP 07

Once you are done, check whether by browsing your servername URL(www.d6technology.lk)

D6 Digital

D6 Digital provides total business solutions to improve efficiency and productivity of your business processes using a combination of existing technology and innovative methods.

Ahmed Thaajwer

Written by

Undergraduate at Sabaragamuwa University of Sri Lanka and Former Student of British College of Applied Studies.Worked at D6 Digital as a Software Engineer

D6 Digital

D6 Digital provides total business solutions to improve efficiency and productivity of your business processes using a combination of existing technology and innovative methods.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade