ServerName and VirtualHosts

ServerName and VirtualHosts

am 27.09.2009 19:23:56 von Stephen

There was a post yesterday about the subject.

I was getting my new server set up with the latest Ubuntu distribution.

The ServerName directive must be added to the config file
(apache2.conf). It was not entered as part of the installation.

>From the docs:

The |ServerName| directive sets the hostname and port that the server
uses to identify itself. This is used when creating redirection URLs.
For example, if the name of the machine hosting the web server is
|simple.example.com|, but the machine also has the DNS alias
|www.example.com| and you wish the web server to be so identified, the
following directive should be used:

| ServerName www.example.com:80 |

If no |ServerName| is specified, then the server attempts to deduce the
hostname by performing a reverse lookup on the IP address. If no port is
specified in the |ServerName|, then the server will use the port from
the incoming request. For optimal reliability and predictability, you
should specify an explicit hostname and port using the |ServerName|
directive.



Note that only if the directive is missing (including the port), does
Apache try to query DNS, and the first step is to look in the hosts file.

Apache does not really need a Server Name if all you are doing is
virtual hosting, but throw something in the apache.conf file anyway.

I also got a warning message: [warn] NameVirtualHost *:80 has no
VirtualHosts

This is caused by an entry in BOTH ports.conf and the virtual hosts
config file for NameVirtualHost.

Delete the one in ports.conf.

Hope this saves someone some time.

Stephen

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org