Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having a few problems when setting up IP-based virtual hosts. First of all I'm using the current XAMPP from apachefriends (XAMPP 1.7.7 with Apache 2.2.21) on Windows 7.

The basic functionality over the "main" server (from httpd.conf) works perfect. But now I want to set up multiple vhosts with different IP-addresses, as I configured my network card to use all IP-addressess from 192.168.2.95 to 192.168.2.105 .

This is the virtual hosts entry:

<VirtualHost 192.168.2.96:80>
    DocumentRoot "/xampp/hegedocs/www"
    ServerName 192.168.2.96:80
</VirtualHost>

httpd -D DUMP_VHOSTS says this:

PS G:\xampp\apache\bin> ./httpd -D DUMP_VHOSTS
VirtualHost configuration:
192.168.2.96:80        192.168.2.96 (G:/xampp/apache/conf/extra/httpd-vhosts.conf:45)
Syntax OK

But I am unable to access the vhost neither seems apache to listen on 192.168.2.96:80 - there is no entry shown for this address with netstat -a -b.

share|improve this question
    
Did you restart the service after making the config change? Have you verified that the process is listening on that port? –  Shane Madden Nov 21 '11 at 5:48
add comment

4 Answers

I found the problem: IP based vhosts just don't work. Just defining a few names in the hosts file (foo.localhost, bar.localhost all mapping to the same IP address) and then using name based vhosts works without any problem. Of course this is not as portable as IP-addresses as other machines in the network naturally don't know these names... but well, as long as it somehow works...

share|improve this answer
add comment

Here are some basic things you could try adding, to make sure you're getting the right port.

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

Here is an example from appache on what it should look like:

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com

# Other directives here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org

# Other directives here

</VirtualHost>

I'm sure you have seen this before, but sometimes it helps to look back at the simple stuff.

My setup works fine running 2 websites on 1 box, using ServerName www.example.com.

Hope this helps!

share|improve this answer
    
Well that did not worked for me. As far as I see all values are correct. Maybe you can spot the error? I uploaded both the httpd.conf and the httpd-vhosts.conf: pastebin.com/HrPE0gJy –  dom0 Nov 20 '11 at 19:19
    
ServerName localhost:80 I'm not sure if the 192.168.2.96 IP is local host, but maybe add the IP there in the httpd.conf . –  Tillman32 Nov 21 '11 at 5:42
1  
I'm now using name based virtual hosts. That works at last ;) –  dom0 Nov 21 '11 at 14:00
add comment

Make sure that apache knows where the vhost.conf file is. At the bottom of httpd.conf, you may have to uncomment

Include conf/*.conf
share|improve this answer
    
Well DUMP_VHOSTS tells me that apache knows about the vhost... syntax is ok, too. I guess it is some kind of apache <-> OS interaction problem... –  dom0 Nov 20 '11 at 22:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.