Welcome to WebmasterWorld Guest from 54.205.251.179

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:

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
     ServerName 127.0.0.1
     DocumentRoot /Users/pamelaparks/Sites
</VirtualHost>

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

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



And in the hosts file looks like this

127.0.0.1      localhost
127.0.0.1      test.officeapp.com
127.0.0.1      test.Baker.com   
255.255.255.255   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

<VirtualHost 127.0.0.1>
     ServerName 127.0.0.1
     DocumentRoot /Users/pamelaparks/Sites
</VirtualHost>

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 192.168.0.2 I can't remember for sure why but I think it was because the 127.0.0.1 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>

<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
</Directory>
</VirtualHost>

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>
[localhost...]
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...