Settings for virtual host in Apache


Step 1 : DNS
open below file in your editor
c:\Windows\System32\Drivers\etc
in above folder we need to open hosts file and then add your new DNS
for example,
127.0.0.1         mydomain.com
127.0.0.1        testdomain.com

Step 2 : Setting for xampp
Now open
xampp\apache\conf\extra
open this file httpd-vhosts.conf
and then we need to create our virtual host
for exmaple,

first we need to define our default localhost

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin localhost
DocumentRoot “c:/xampp/htdocs/”
ServerName localhost
</VirtualHost>

and then we need add one more host

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin mydomain@localhost.com
ServerName mydomain.org
ServerAlias mydomain.org testdomain.org
DocumentRoot “c:/xampp/htdocs/proejctname”
</VirtualHost>

Last step we need to restart apache and then we can open our site as we defined in DNS

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s