Welcome to WebmasterWorld Guest from

Forum Moderators: travelin cat

Message Too Old, No Replies

Setting up Virtual Hosting



12:20 am on Nov 22, 2003 (gmt 0)

10+ Year Member

I set up virtual hosting for a site
in the httpd.conf:

     DocumentRoot /Users/pamelaparks/Sites

<VirtualHost test.officeApp.com>
   ServerName test.officeApp.com
   DocumentRoot /Users/pamelaparks/Sites/officeApp/

<VirtualHost test.Baker.com>
   ServerName test.Baker.com
   DocumentRoot /Users/pamelaparks/Documents/WebDesignPam/MySites/Baker_folder/Baker

And in the hosts file looks like this      localhost      test.officeapp.com      test.Baker.com   broadcasthost
::1             localhost 

Then I ran a sudo apachectl graceful.. it restarted. Then I tried test.officeApp.com and test.Baker.com in a browser and I get the baker site when the url used is test.officeApp! test.Baker.com gives me a server not found and then when I retry the test.officeApp I get a listing of the contents of Sites. This seems really weird!

It does seem odd to me to

     DocumentRoot /Users/pamelaparks/Sites

but did so because of an O'Reilly article on locating Web Site Files


3:58 am on Nov 22, 2003 (gmt 0)

10+ Year Member

Is your Mac hooked up to a router? I did this awhile back but I used NameVirtualHost I can't remember for sure why but I think it was because the did not work right for me.

If your are hooked up to a router, you could try using the ip that it gives your Mac and make the changes in httpd.conf and hosts. Thats the way I did it and it worked for me.


4:21 pm on Nov 22, 2003 (gmt 0)

10+ Year Member

I don't like your usage of ip-numbers and host-names in the <VirtualHost>

Try this instead:

NameVirtualHost *
<VirtualHost *>

<VirtualHost *> 
ServerAdmin mozilla@mathiesen.info
ServerName test.mozilla.info
DocumentRoot "/Volumes/brugere/bjarnema/Mozilla/Documents"
<Directory "/Volumes/brugere/bjarnema/Mozilla/Documents">
Options Indexes
AllowOverride All
Order allow,deny
Allow from all

The first empty VirtualHost will default to the way the server has been configured in the main body of the httpd.conf file.

The following URL should give you the manual entry for <VirtualHost>
at least with Apache 2.0.x - might be different if you are using Apache 1.3.x


4:45 pm on Nov 25, 2003 (gmt 0)

10+ Year Member

did you open NetInfo Manager under the utilities folder?

you have to create an appropriate machine for each virtual folder.


8:06 pm on Nov 25, 2003 (gmt 0)

10+ Year Member

It's not necessary to mess around with Netinfo Manager.
Editing the file /etc/hosts is quite suffcient no matter what the comment in /etc/hosts says.

If yoo do a 'lookupd -configuration' you'll find the following lines:

LookupOrder: Cache FF DNS NI DS 
_config_name: Host Configuration

which means that the lookupd daemon first tries to find a hostname in the following order:
- it's own cache
- in flat files (FF) like /etc/hosts
- DNS lookup
- NetInfo
- DS
so /etc/hosts is in fact apparently consulted before NetInfo


5:16 pm on Nov 27, 2003 (gmt 0)

10+ Year Member

really... without setting up the NetInfo Manager for me was impossible to make the VirtualHost working...

Featured Threads

Hot Threads This Week

Hot Threads This Month