Problems with setting up virtual domains (virtual hosting)
1. I've set up a name based virtual domain but I can't get to it from the web. It shows up fine when I look at it with lynx on the localhost or from my PC in the office but nobody can find it on the web, they keep getting some sort of error about host not found. What's the problem?
Is this a registered domain and it's in the root nameservers? It may be that you've got the domain listed in your local DNS but if it's not in the root nameservers and not registered with one of the NIC's it's not gonna work.
2. I've set up an ip based virtual domain but I can't get it to work by name, only by ip address. Why?
See the answer to question #1.
3. What should an ip based VirtualHost directive look like?
This example is straight out of the stock SWS httpd.conf file.
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
#
<VirtualHost ip.address.of.host.some_domain.com/>
ServerAdminwebmaster@host.some_domain.com
DocumentRoot /www/docs/host.some_domain.com
ServerName host.some_domain.com/
ErrorLog logs/host.some_domain.com-error_log
CustomLog logs/host.some_domain.com-access_log common
</VirtualHost>
4. What should a name based VirtualHost directive look like?
There are two parts to this. The first one is that you must issue a directive which gives Apache an ip address to serve the name based domains from. Like this:
#
# If you want to use name-based virtual hosts you need to define at
# least one IP address (and port number) for them.
#
NameVirtualHost 12.34.56.78:80
NameVirtualHost 12.34.56.78
The second part is then to add the VirtualHost directives for each domain. Like this:
# VirtualHost example (name based):
# Almost any Apache directive may go into a VirtualHost container.
#
<VirtualHost name.of.host.some_domain.com/>
ServerAdmin webmaster@host.some_domain.com
DocumentRoot /www/docs/host.some_domain.com
ServerName host.some_domain.com/
ErrorLog logs/host.some_domain.com-error_log
CustomLog logs/host.some_domain.com-access_log common
</VirtualHost>