httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Httpd Wiki] Update of "TroubleshootingVhosts" by SeanTimmins
Date Fri, 11 Jan 2013 19:28:29 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.

The "TroubleshootingVhosts" page has been changed by SeanTimmins:

New page:
= TroubleShooting Virtual Hosts =
The page will concentrate on Named Base virtual hosts mainly because it is what most people
use and it is the one most people seem to have problems with. Some things are 2.2 only and
are marked as such.

== The Basics ==
Virtual Hosts are much simpler than most people seem to think. This is not helped by some
unusual 'default' virtual hosts setups distributed by some of the major distributions.

First of all '''read the documentation'''!
 * ExampleVhosts

Secondly, and I can't stree this enough, '''USE''' "apachectl -S", "httpd -S" or "apache2ctl
-S" whenever you make any change to your configuration. It outputs various lines of information
that are vital to troubleshooting virtual host configuration.

== The Requirements ==
 * (2.2 only) You '''must''' have a [[|NamedVirtualHost]]
directive for each IP+port combination you wish to use, it should be IP:port or *:port

 NameVirtualhost *:80

 * Each [[|<VirtualHost>]] directive should
have and IP:port inside it, in httpd 2.2 this should match your [[|NamedVirtualHost]]

 <VirtualHost *:80>

 * Each virtual host '''must''' have its own unique [[|ServerName]].
It is this that must match the host component of the URL that the user types into their browser.
If you define a second virtual host with the same server name then whichever virtual host
comes first in the configuration will be the only one that works with that name.

 * Each virtual host should also have its own distinct [[|DocumentRoot]].
Although it is possible and in a few cases needed to share document roots, it is normally
better to use a single virtual hosts with server aliases.

 DocumentRoot /var/www/foo

== The First Virtual Host ==
With named base virtual hosts, the first one apache finds in the configuration files is special.
This is the one that requests will be passed to if apache has no way to determine which specific
virtual host to use. It is the '''default''' virtual host.

If the user types `` then it is the string ``
that is matched against the host component of the [[|ServerName]]
or any [[|ServerAlias]] (Remember
Server``Name can contain an optional schema and port)

''Advanced Note:'' It is actually the contents of the `Host` header that is used rather than
the host component of the URL. Though these would normally be the same.

== Virtual Host Example ==

# any request to, or indeen anything other than that resolves
# to will hit this first virtual host
  DocumentRoot /var/www/foo

# Only URLs that start http:/// or will hit this
# virtual host
  DocumentRoot /var/www/bar

== Troubleshooting ==
The [[|ErrorLog]] is always the
first place to look when you get any problems, but there are things you can do to make troubleshooting
virtual hosts easier.

 * Give each virtual host its own access and error log. this will enable you to easily separate
out requests to each virtual host and in particular verify a particular request is actually
hitting the virtual host you think it is. An alternative for determining the virtual host
a request hits is to add `%v` to the [[|LogFormat]]

=== Log Files ===

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message