Forum Moderators: phranque
I can set the host file to whatever I want and the server works but as soon as I setup a virtualhost for one of the hosts, the whole thing comes crashing down.
I set the hosts to the following:
127.0.0.1 localhost
127.0.0.2 example.no-ip.com
I tried the virtualhosts as such:
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web
ServerName localhost
</VirtualHost>
NameVirtualHost example.no-ip.com:80
<VirtualHost example.no-ip.com:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web/example
ServerName example.no-ip.com
</VirtualHost>
but that didnt work.
So I tried it like this:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web
ServerName localhost
</VirtualHost>
NameVirtualHost 127.0.0.2:80
<VirtualHost 127.0.0.2:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web/example
ServerName example.no-ip.com
</VirtualHost>
But that didnt work either so I tried it with only one "NameVirtualHost localhost" for all virtualhosts, I tried a "*" for the NameVirtualHosts and VirtualHosts and I tried and tried and tried for 5 days now but still cant get the VirtualHosts working.
Someone Please Help Me, Im Going Nuts!
[edited by: jdMorgan at 4:08 pm (utc) on April 1, 2005]
[edit reason] Removed specifics per TOS. [/edit]
NameVirtualHost 127.0.0.1:80
Secondly, I generally recommend that all NameVirtualHost lines be next to one another, as it keeps the httpd.conf a bit more readable:
NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.2:80
<VirtualHost 127.0.0.1:80>
(config for this vhost)
</VirtualHost>
<VirtualHost 127.0.0.2:80>
(config for this vhost)
</VirtualHost>
Third, saying "it doesn't work" doesn't really help with troubleshooting. I'm assuming that when you access a particular virtualhost in a web browser, you don't see what you expect. So, what *do* you see? Are there any messages in the error log?
127.0.0.1 localhost
127.0.0.2 example.no-ip.com
127.0.0.3 stuper.no-ip.com
127.0.0.4 fortheorphs.tk
127.0.0.5 www.example.com.au
127.0.0.6 ISSSG.tk
Conf file:
NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.2:80
NameVirtualHost 127.0.0.3:80
NameVirtualHost 127.0.0.4:80
NameVirtualHost 127.0.0.5:80
NameVirtualHost 127.0.0.6:80<VirtualHost 127.0.0.1:80>
ServerAdmin hurt_domain@hotmail.com
DocumentRoot C:/web
ServerName localhost
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost 127.0.0.2:80>
ServerAdmin sales@example.com.au
DocumentRoot C:/web/example
ServerName example.no-ip.com
</VirtualHost>
<VirtualHost 127.0.0.3:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web/stuperfied
ServerName stuper.no-ip.com
</VirtualHost>
<VirtualHost 127.0.0.4:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web
ServerName fortheorphs.tk
</VirtualHost>
<VirtualHost 127.0.0.5:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web/example
ServerName www.example.com.au
</VirtualHost>
<VirtualHost 127.0.0.6:80>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web
ServerName ISSSG.tk
</VirtualHost>
The access log reports an access, the error log reports no nothing.
Internet explorer reports:
The page cannot be displayed.
Jargon about please try the following.
Cannot find server or DNS error.
[edited by: jdMorgan at 3:48 am (utc) on April 11, 2005]
[edit reason] Examplified [/edit]
Q. Do you have listen directives for those ip's.
A. I have the listen directive set as "*:80".
Q. Did I restart my browser after I modified the hosts file.
A. I openned a new browser when I tried to access the server remotely from my computer and tried two of the name bassed url's mentioned but only got the IE error page. I also oppenned a new browser window when I tried to access the sites using the same 2 name bassed url's mentioned locally from the server however this time, the "http://fortheorphans.tk" name brought up the control panel page but the "http://example.no-ip.com" name failed and produced the IE error page.
Q. If I setup custom logs do they get logged in the right place.
A. Havent tried but will do so when I get back as im about to go out now.
Thank you once again very much for helping me with this, I hope the information I have supplied is easily understood and helpfull.
[edited by: jdMorgan at 3:49 am (utc) on April 11, 2005]
[edit reason] Examplified. [/edit]
Unfortunately none of the pages will come up when using a name based url remotely.
Define 'remotely'; you do know that any IP address that starts with "127." isn't going to be accessible from any host *except* the host itself, right? =)
I openned a new browser when I tried to access the server remotely from my computer
I don't think that's sufficient; you'll probably have to exit the browser completely and start it back up again. Or, to be safe, you could just reboot. =)
Define 'remotely'; you do know that any IP address that starts with "127." isn't going to be accessible from any host *except* the host itself, right? =)
This could be the problem. I want the websites to be able to be accessable over the internet like msn.com, nokia.com etc. If the IP range of "127" wont do that then which IP range should I use and should I still put it in the hosts file?
All the hosts file does is provide IP->hostname mappings that can be used by the host the hosts file is on. If you want *other* hosts to to be able to look up the IP of your site, the domain needs to be registered with one of the domain registrars (dotster [dotster.com], domainmonger [domainmonger.com], etc) and the hostname placed in DNS. You can verify that a domain has been registered by using a 'whois' tool, such as GeekTools [geektools.com].
Once this has been verified, the hostname needs to placed in DNS, mapped to the IP address of your server. You do NOT need a seperate IP address for each site *unless* you're going to be using SSL (HTTPS). Read [httpd.apache.org ] for more info on configuring name-based virtualhosts under Apache.
Once this has been verified, the hostname needs to placed in DNS, mapped to the IP address of your server.
Ok, "example.no-ip.com" and "stuperfied.no-ip.com" are registered with no-ip.com and are pointed at our servers Internet IP address. "fortheorphans.tk" and "ISSSG.tk" are registered with "http://www.dot.tk" which is another free domain name provider and also point at our servers Internet IP address. "example.com.au" however was registered by our host AVS Networks "http://www.avs.net.au" so I have no idea who its registered with but it currently points at their server and is a fully functional domain. When we get our server working properly we want to point "example.com.au" at our server.
I should mention that all domain names do work but we have to map them directly to their directory on the server, however as soon as we setup a virtual hosts they stop working.
So how do we place the host name in DNS and map it to the IP address of our server and what should the Virtual Hosts be set to?
[edited by: jdMorgan at 3:50 am (utc) on April 11, 2005]
[edit reason] Examplified. [/edit]
So how do we place the host name in DNS and map it to the IP address of our server and what should the Virtual Hosts be set to?
In this case, registering them with no-ip.com has placed them in DNS; this can be verified by running 'host WHATEVER.no-ip.com' (had you registered your own domain, you'd then need to find DNS hosting for your domain and create the proper entries in your domain's zonefile).
The only thing still required is NameVirtualHost entries for the IP you've registered with no-ip.com, and <VirtualHost> blocks for each site, configured with a ServerName foo.no-ip.com, or what have you. For instance:
#
# use your real IP here
NameVirtualHost 192.168.1.100:80
#
# ...and here
<VirtualHost 192.168.1.100:80>
ServerName yourhostname.no-ip.com
DocumentRoot /path/to/host/docroot
(other directives here)
</VirtualHost>
NameVirtualHost *<VirtualHost *>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web
ServerName fortheorphs.tk
ServerAlias fortheorphans.tk *.fortheorphs.tk
</VirtualHost>
<VirtualHost *>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web/example
ServerName www.example.com.au
ServerAlias example.com.au *.example.com.au
</VirtualHost>
<VirtualHost *>
ServerAdmin hurt_domain@hotmal.com
DocumentRoot C:/web/ISSSG
ServerName ISSSG.tk
ServerAlias ISSSG.tk *.ISSSG.tk
</VirtualHost>
Now all my domain names are being refered to the first VirtualHost, they are all ignoring the rest of them. Whatever DocumentRoot I set the fortheorphans.tk VirtualHost to is the one that all sites are being sent to. Also if I try to set a virtual host for a no-ip.com domain, it all stops working again. The only thing I can think of is that maybe the .tk and no-ip.com servers dont send the host name in the header file. The www.example.com.au host is just for show, it really points at the AVS Networks server.
Idea's?
[edited by: jdMorgan at 3:52 am (utc) on April 11, 2005]
[edit reason] Examplified. [/edit]