Forum Moderators: phranque
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
127.0.0.1 localhost
127.0.0.1 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
</VirtualHost>
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 127.0.0.1 instead of * in httpd.conf, and 127.0.0.2 instead of 127.0.0.1 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.
- 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 127.0.0.1, 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.
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 127.0.0.1 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>
<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
</VirtualHost>
Let me know.
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.