homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Virtual hosts problem with Apache
On a Windows XP system

 5:22 pm on Jun 7, 2002 (gmt 0)


I am having trouble getting virtual hosts to run on my local machine. I use Apache 2 on Windows XP.

I have read the Apache manual many times and also found examples of how to do it in other sources.
Although I think I am doing what I should it still does not work.

The problem is that I can't browse the site - Windows wants to connect to the Internet instead of getting the virtual host's HTTP files from the file system.

This is the content of my "hosts" file localhost www.virtualhost.com

(BTW, where on earth does the Apache manual you need to edit it?)

This is the relevant part of httpd.conf

NameVirtualHost *

<VirtualHost *>
ServerAdmin office@virtualhost.com
DocumentRoot d:/temp
ServerName www.virtualhost.com
ErrorLog logs/virtualhost.com-error_log
CustomLog logs/virtualhost.com-access_log common

I can ping www.virtualhost.com from a command prompt, but when I enter www.virtualhost.com in the Internet
Explorer address bar, Windows starts to connect to the Internet, which is not what I want.

I also tried instead of * in httpd.conf, and instead of in hosts and httpd.conf.

I am also unsure of whether the ServerName has anything to do with it or not.

Any ideas would really be appreciated.



 6:18 pm on Jun 7, 2002 (gmt 0)

try surfing or localhost in your IE address bar.


 5:46 am on Jun 8, 2002 (gmt 0)

luc: Thx for your replay, but that just brings up the HTML file stating that Apache is installed correctly.
The idea of virtual hosts is to have several of them though, so I need to be able to enter the actual virtual host name, not just local host.


 11:10 am on Jun 8, 2002 (gmt 0)

Searching google groups usually works for stuff like this. If you want to serve both the default doc root and the virtual host root, I think you need two virtual host entries. Or use localhost for the default server, and another ip (like for the virtual host. Just guessing, I haven't tried it on windows, but just set up a home test server on linux, that I can reach from a networked win2k machine.


 3:10 am on Jun 15, 2002 (gmt 0)

From what I've seen, it appears as though you've chosen www.virtualhost.com as a way to test virtual hosting for Apache. However, you cannot do this unless you're running a local DNS server that has the domain virtualhost.com setup. Does this make sense? When you type in www.virtualhost.com it's going to hit the DNS server you currently have setup which is likely your ISP and hence why it's hitting the Internet.


 5:17 am on Jun 15, 2002 (gmt 0)

This is an interesting answer. I figured the hosts file would sort of do the job of the DNS server, but maybe I'm mistaken.
Does anyone know?


 5:47 am on Jun 15, 2002 (gmt 0)

The hosts file is supposed to overstep the DNS server but it does not always work. I would suggest changing it from www.virtualhost.com to just virtualhost. I am sure there is an actual www.virtualhost.com which is where the problem is probably coming from. When you use a Domain instead of a name for local testing like this its asking for issues. Pluse virtualhost is easier to type than www.virtualhost.com.


 6:19 am on Jun 15, 2002 (gmt 0)

What I am actually trying to do is edit and test a web page offline. So the domain I type in the address bar (and hosts file) definitely does exist in the internet (and it should).
I need to be able to use the complete domain name, otherwise I won't be testing the real thing. But why does IE try to connect to the internet, and what can I do to stop it?


 12:33 pm on Jun 15, 2002 (gmt 0)

Ya just virtualhost isn't going to work either. IE will try and translate that into virtualhost.com, www.virtualhost.com, etc as I'm sure you're experiencing. Your Internet connectivity is setup with external DNS servers so everytime you try to hit something on the Internet, it tries to resolve the names by using the external DNS servers. If you had a local DNS server, and setup your Internet connection to use that, you could essentially setup ANY domain you wanted to. Look into [jhsoft.com...] (Simple DNS). If you need help setting it up let me know.


 2:25 pm on Jun 19, 2002 (gmt 0)

OK, I downloaded and installed Simple (?) DNS Plus. Can't figure it out at all though :-(

- I don't understand why the help file says the domain must be registered in the Internet - what I'm trying to do is make the whole thing to happen offline, so the domain name shouldn't matter at all.

- When I start the DNS server, I get the message "Could not start DNS service on, error 10048. Port 53 may be in use by another program." Internet Connection Sharing is not involved.

- How do I tell Windows to stop using an external DNS server (assuming that is the problem)

- How do I map the various virtual hosts to the file system?

I surprised how difficult this is considering it's supposed to work out of the box according to Apache.


 2:31 pm on Jun 19, 2002 (gmt 0)

solvik you got me thinking so I tried this the other day at home. I did get it to map through to a .info address. Unfortionally it also remapped my localhost so I didnt do something right. You have to add it to the Hosts file as www.virtualhost.com or in my case .info. Also make sure you are restarting your apache server after making the changes. This means a full reboot from what I can tell if its running as a service.


 3:36 pm on Jun 19, 2002 (gmt 0)

You should never have to reboot to bounce the Apache service. If you're on NT/2k, just go into the Services Control Panel and start/stop. Else, it should be in a DOS window so just close and restart the daemon.

At any rate, Solvik-

Yes this is not as easy as it seems :-)

Don't worry about its warning about must be registered on the Internet. That's only if you were serving up the site externally, which you're not going to do. You're just running an Internal DNS server. You don't want to tell Windows to stop using the external DNS, but to use the Internal DNS in addition. What OS are you running? You'll need to add to your DNS servers. As far as not being able to use port 53, that is odd. Again, I need to know the OS. As far as mapping the virtualhosts, that is the easy part. You're going to create some dummy domains on the DNS server once it's up, say mytestdomain.com, and mytestdomain2.com. Then you'll have to define A records for both domains so you can create www. I can help you with this once you actually get your server up. Email me, it'll be easier that way. As for virtualhosts file you'll define a couple of virtualhosts entries like:

NameVirtualHost *

<VirtualHost *>
ServerAdmin me@me.com
DocumentRoot d:/temp
ServerName www.mytestdomain.com
#ErrorLog logs/virtualhost.com-error_log
#CustomLog logs/virtualhost.com-access_log common
<VirtualHost *>
ServerAdmin me@me.com
DocumentRoot d:/temp
ServerName www.mytestdomain2.com
#ErrorLog logs/virtualhost.com-error_log
#CustomLog logs/virtualhost.com-access_log common

Let me know.


 1:52 pm on Aug 26, 2002 (gmt 0)

Is this only in IE?

In IE I had to change the Connections options to 'Never dial a connection'.

Even then depending on platform [?] the first time I request a particular local domain it gives me some prompt about Connect[?] or Try Again. Try Again then connects correctly.

Sorry for the vagueness on a couple of issues but I don't have immediate access to the setup on which this occurs.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved