Need Help in virtual host

Alles, was den Apache betrifft, kann hier besprochen werden.

Need Help in virtual host

Postby spicyjazz » 25. December 2007 14:30

Hi,

I'm Dinesh and Im new to Apache.

With apache tutorials I had made some virtual host and I have configured the host file in windows folder. I works great, but when I test in other computer which is connected to lan, I can view only the default website but not the other virtual hosts I made. When I refer the tutorials im getting confused with it. Can u please provide a soluton for it.

My Apache httpd.conf files goes here

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.2>
ServerName "site1"
DocumentRoot "SitePath"
</VirtualHost>

<VirtualHost 127.0.0.3>
ServerName "site2"
DocumentRoot "SitePath"
</VirtualHost>

<VirtualHost 127.0.0.4>
ServerName "Site3"
DocumentRoot "SitePath"
</VirtualHost>

<VirtualHost 127.0.0.5>
ServerName "Site4"
DocumentRoot "SitePath"
</VirtualHost>

My Hosts File is configured like this

127.0.0.1 localhost
127.0.0.2 site1
127.0.0.3 site2
127.0.0.4 site3
127.0.0.5 site4

All the sites are working great but when tested in lan or other computer which is connected through lan it doesn't show anything. can u please provide a solution for it.

If possible can u please provide solution for not only intranet as well as internet if possible.

Awaiting for your response.

Thanks.
:)
spicyjazz
 
Posts: 1
Joined: 25. December 2007 14:25

Postby glitzi85 » 22. January 2008 01:26

Hello,

Neither this can work as a fact of wrong Syntax, nor will this work in Internet, as of using the Loopback Address in the VirtualHosts. Use this Syntax for general use:

Code: Select all
NameVirtualHost *

<VirtualHost *>
   ServerName site1
   DocumentRoot /absolute/path/to/site1
</VirtualHost>


And so on for the other sites. If you want to keep your localhost, you need to define one VirtualHost-Block for the localhost (with the Path you will find in the DocumentRoot-Settings also in yout httpd.conf).

Just for Information. If the Apache Webserver get's a request with an URL he can not find in one VirtualHost-Block, he will use the first Block, so be careful what you write on the first position.

@Mods: Wäre der Beitrag im Englischen Teil nicht besser aufgehoben?

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim


Return to Apache

Who is online

Users browsing this forum: No registered users and 5 guests