Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache W32 using Virtual Hosts

Status
Not open for further replies.

Zych

IS-IT--Management
Joined
Apr 3, 2003
Messages
313
Location
US
Hey People,

I am having problems getting the virtual host part working on my Apache2 running on Windows 2000 Pro. I just started palying with it yesterday so I am real new to it. So far I have configured PHP4 which I have tested OK, but when I try to go to a virtual host it goes back to the default screen. I have bound 5 private IP's to the NIC and then added them to the conf file to test it out. (By the way this is just a system I am setting up so I can learn PHP.) On one of my other workstations I have added the first domain to my host file and can ping it fine. Here is my VirtualHost section of my httpd.conf file:

<VirtualHost 192.168.2.230:80>
ServerAdmin Admin@lsinet.com
DocumentRoot "C:/ ServerName lantecsystems.com
ErrorLog logs/LSIHost.lantecsystems.com-error_log
CustomLog logs/LSIHost.lantecsystems.com-access_log common
</VirtualHost>
<VirtualHost 192.168.2.231:80>
ServerAdmin Admin@lsinet.com
DocumentRoot ServerName CJKolanda.CJKolanda.com
ErrorLog logs/CJKolanda.CJKolanda.com-error_log
CustomLog logs/CJKolanda.CJKolanda.com-access_log common
</VirtualHost>
<VirtualHost 192.168.2.232:80>
ServerAdmin Admin@lsinet.com
DocumentRoot ServerName Mortgage.MortgageandLoans.com
ErrorLog logs/Mortgage.MortgageandLoans.com-error_log
CustomLog logs/Mortgage.MortgageandLoans.com-access_log common
</VirtualHost>

As you can see I have changed the first one a couple of times copying what I have seen in others conf file such as using c: in "". The is in two places now. One is of the root C:\ and the other is in the Apache2 directory. I will end up deleting one of them when I am done and get it working. I have an index.html file in the lantecsystems.com directory which has been tested under IIS. Any ideas on getting this to work? Is there another part of the conf file that tells the system to use ip virtual hosts?

Thanks,

Zych
 
Is there a reason for using ip based addressing rather than name based? Name based is much simpler. Just make sure the follow directives are defind this way:

UseCononicalNames Off
Listen *:80
NameVirtualHost *

Then just use the wildcard for the vhost containers:

<VirtualHost *>

Apache will try to match the requested domain to ServerName in each vhost. Ip based addressing is a little different. I assume that when you say you bound these ip addresses to your NIC, that you created virtual interfaces (ip aliasing) such as eth0:1, eth0:2 etc. with each having their own ip. This comes in handy when you plan on using SSL virtual hosts. You should have to make many changes at all. I think you will need to turn UseCanonicalName back On if it is set to Off. Make sure apache "Listens" for ALL addresses and comment out the NameVirtualHost directive. Make sure to restart apache every time you edit httpd.conf.
 
The reason I used IP is that is what I did with IIS when I used it. I take it that the name based uses the name in the address field to look up the right web page?

You are also correct on the IP aliasing. I see that you are a Linux person by the way you are refering to eth0:1 etc. I am starting to take a look at ApacheAdmin to see if it finds something but I have never used it before. From what I could tell I have done everything correct but it still doesn't work. I guess I need to do some more web searching.

Thanks,

Zych
 
I have now tried using names but still no go. Here is my latest conf file:

NameVirtualHost 192.168.2.230:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
<VirtualHost 192.168.2.230:80>
ServerAdmin admin@localhost
DocumentRoot "c:/ ServerName localhost
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>
<VirtualHost 192.168.2.230:80>
ServerAdmin Admin@lsinet.com
DocumentRoot "C:/ ServerName lantecsystems.com
ServerAlias *.lantecsystems.com
ErrorLog logs/lantecsystems-error.log
CustomLog logs/lantecsystems-access.log common
<Directory "C:/ Options All Includes Indexes
</Directory>
</VirtualHost>

Anybody have any ideas? This is driving me crazy and all the documentation I see shows I have it correct more or less. (Some include the directory and some did not.)

Please help before I loose it.

Thanks,

Zych
 
Does apache start and/or restart ok? If it does, then look in your logs directory and check the error_log. If you can't make heads or tails of it, post the last few lines here and we will help you get it sorted out.
 
Here is the last part of the error log. It repeats this throughout. The error logs for each virtual system is created but they are all 0 length.

[Tue Jun 22 17:02:54 2004] [notice] Parent: Received restart signal -- Restarting the server.
[Tue Jun 22 17:02:54 2004] [notice] Child 120: Exit event signaled. Child process is ending.
[Tue Jun 22 17:02:54 2004] [notice] Parent: Created child process 1384
[Tue Jun 22 17:02:54 2004] [notice] Child 1384: Child process is running
[Tue Jun 22 17:02:55 2004] [notice] Child 120: Released the start mutex
[Tue Jun 22 17:02:55 2004] [notice] Child 1384: Acquired the start mutex.
[Tue Jun 22 17:02:55 2004] [notice] Child 1384: Starting 250 worker threads.
[Tue Jun 22 17:02:56 2004] [notice] Child 120: Waiting for 250 worker threads to exit.
[Tue Jun 22 17:02:56 2004] [notice] Child 120: All worker threads have exited.
[Tue Jun 22 17:02:56 2004] [notice] Child 120: Child process is exiting

I have found another thread on another forum which leads me to think this may be a bug in the latest release. Here is the link to that forum:
- Zych
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top