OT:Apache question - what should really be in /etc/hosts?

Rick Stevens rstevens at vitalstream.com
Mon Feb 23 18:04:38 UTC 2004


Mark Knecht wrote:
> On Sat, 2004-02-21 at 09:21, Mark Knecht wrote:
> 
> 
>>With that entry removed....
> 
> 
> Chris,
>    OK, this is interesting. I got it working, at least on my home
> network. Maybe you can check it quickly from there if you get the
> message.
> 
> http://marksmusic.myvnc.com
> http://marksmusic.myvnc.com/files
> 
> 
>    I had removed the /etc/hosts entry for the machine as before, and
> then I decided to restart apache. I got a message that it could not
> determine the fully qualified name of the server. So I edited the entry
> in /etc/hosts to look like this:
> 
> 192.168.1.26    marksmusic.myvnc.com    Wizard
> 
> restarted Apache and now it's working from all of my machines.
> 
> As I had originally said in my very first email (I think) I've never
> knowne the *right* way to set up a hosts file on a home studio network
> where I don't run DNS and don't map (technically) to the outside world. 
> 
> Is the entry above technically correct? Can I have a fully qualified
> name that's different from the machine name?

Yes, that's a correct /etc/hosts entry.  The trick is that you
apparently have either a "ServerName" directive in your main config file
with one of the names OR you have a "VirtualHost" directive with only
one of the names in it.  If you have a ServerName directive OUTSIDE
the VirualHosts, it must be a FQDN and you're only allowed one name.

For a wildcard setup, have a "<VirtualHost *>" directive and do NOT
include a "ServerName" inside it at all (the system will try to match
the host header against the ServerName).  Here's an example from the
manual:
-----------------------------------------------------------------------
Simple name-based vhosting

* Compatibility: This syntax was added in Apache 1.3.13.
* Setup: The server machine has a primary name server.domain.tld.  There
are two aliases (CNAMEs) www.domain.tld and www.sub.domain.tld for the
address server.domain.tld.

Server configuration:

     ...
     Port 80
     ServerName server.domain.tld

     NameVirtualHost *

     <VirtualHost *>
     DocumentRoot /www/domain
     ServerName www.domain.tld
     ...
     </VirtualHost>

     <VirtualHost *>
     DocumentRoot /www/subdomain
     ServerName www.sub.domain.tld
     ...
     </VirtualHost>


The asterisks match all addresses, so the main server serves no
requests. Due to the fact that www.domain.tld is first in the
configuration file, it has the highest priority and can be seen as the
default or primary server.
-----------------------------------------------------------------------

The manual should be available at http://marksmusic.myvnc.com/manual/
(note the trailing slash).
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-      I won't rise to the occasion, but I'll slide over to it.      -
----------------------------------------------------------------------





More information about the Redhat-install-list mailing list