How can I add a virtual host in apache ?
How do I add another local domain into apache ?
How do I add another site in apache ?

15 July 2004, 10:01 am IST
User Rating: 6.8 (30 votes)

First select a domain name for the site like www.mysite2.loc

Next add this to your HOSTS file. You can find this file at the following locations depending upon your operating system.

/etc/hosts in Linux C:\WINDOWS\system32\drivers\etc\hosts in Windows XP/2000/2003 C:\WINDOWS\hosts in Windows 95/98/Me

Add the ip address and domain name of the site to it. If the site is on your local system, then the ip address is mysite2.loc www.mysite2.loc

Now create a folder where all the site's content would be placed like d:\www\mysite2.

Now add the reference of to apache's configuration file httpd.conf

<VirtualHost> ServerName mysite2.loc ServerAlias www*.mysite2.loc DocumentRoot D:\www\mysite2 <Directory "D:\www\mysite2"> Options Indexes FollowSymLinks +Includes +ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>

Save the file and then restart the apache and you are done.

Note: The options above are for local site hosted on a local server. For more seure server, the options are different.

Rate this knowledge base item

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
blog comments powered by Disqus



Amit Arora is web developer with expertise in developing eCommerce enabled websites for the businesses.

Contact | Resume

Subscribe to newsletter

Get Firefox

Monitored by Site24x7