Name
<VirtualHost>
Synopsis
<VirtualHosthost
[:port
]> ... </VirtualHost> Server config
The <VirtualHost>
directive within a Config file acts
like a tag in HTML: it introduces a block of text containing
directives referring to one host; when we’re
finished with it, we stop with
</VirtualHost>
. For example:
.... <VirtualHost www.butterthlies.com> ServerAdmin sales@butterthlies.com DocumentRoot /usr/www/APACHE3/APACHE3/site.virtual/htdocs/customers ServerName www.butterthlies.com ErrorLog /usr/www/APACHE3/APACHE3/site.virtual/name-based/logs/error_log TransferLog /usr/www/APACHE3/APACHE3/site.virtual/name-based/logs/access_log </VirtualHost> ...
<VirtualHost>
also specifies which IP
address we’re hosting and, optionally, the port. If
port
is not specified, the default port is
used, which is either the standard HTTP port, 80, or the port
specified in a Port
directive (not in Apache v2).
host
can also be _default_
, in which case it matches anything no other
<VirtualHost>
section matches.
In a real system, this address would be the hostname of our server. There are three more similar directives that also limit the application of other directives:
<Directory>
<Files>
<Location>
This list shows the analogues in ascending order of authority, so
that <Directory>
is overruled by
<Files>
, and
<Files>
by
<Location>
. Files can be nested within
<Directory>
blocks. Execution proceeds in
groups, in the following order:
<Directory>
(without regular expressions) and .htaccess are executed simultaneously. ...
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.