configuring.html revision 1bea731bc1c7e256ec652da11848312162dda311
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<HTML>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<HEAD>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<TITLE>Configuration Files</TITLE>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna</HEAD>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<BODY
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna BGCOLOR="#FFFFFF"
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna TEXT="#000000"
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna LINK="#0000FF"
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna VLINK="#000080"
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna ALINK="#FF0000"
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<!--#include virtual="header.html" -->
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<H1 ALIGN="CENTER">Configuration Files</H1>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<ul>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<li><a href="#main">Main Configuration Files</a></li>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<li><a href="#syntax">Syntax of the Configuration Files</a></li>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<li><a href="#modules">Modules</a></li>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<li><a href="#scope">Scope of Directives</a></li>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<li><a href="#htaccess">.htaccess Files</a></li>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<li><a href="#log">Log Files</a></li>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna</ul>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<hr>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<H2><a name="main">Main Configuration Files</a></H2>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<table border="1"><tr><td valign="top">
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<strong>Related Modules</strong><br><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<a href="mod/mod_mime.html">mod_mime</a><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna</td>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<td valign="top">
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<strong>Related Directives</strong><br><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<A HREF="mod/core.html#ifdefine">&lt;IfDefine&gt;</A><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<a href="mod/core.html#include">Include</a><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<A HREF="mod/mod_mime.html#typesconfig">TypesConfig</A><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna</td></tr></table>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<P>Apache is configured by placing <A HREF="mod/directives.html"
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna>directives</A> in plain text configuration files. The main
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaconfiguration file is usually called <CODE>httpd.conf</CODE>. The
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernalocation of this file is set at compile-time, but may be overridden
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernawith the <CODE>-f</CODE> command line flag. In addition, other
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaconfiguration files may be added using the <CODE><A
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaHREF="mod/core.html#include">Include</A></CODE> directive. Any
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernadirective may be placed in any of these configuration files. Changes
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernato the main configuration files are only recognized by Apache when it
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernais started or restarted.</p>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<P>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaThe server also reads a file containing mime document types; the
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernafilename is set by the <A HREF="mod/mod_mime.html#typesconfig"
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna>TypesConfig</A> directive, and is <CODE>mime.types</CODE> by default.
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<hr>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<H2><a name="syntax">Syntax of the Configuration Files</a></H2>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<P>Apache configuration files contain one directive per line. The
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaback-slash "\" may be used as the last character on a line to indicate
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernathat the directive continues onto the next line. There must be no
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaother characters or white space between the back-slash and the end of
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernathe line.
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<P>Directives in the configuration files are case-insensitive, but
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaarguments to directives are often case sensitive. Lines which begin
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernawith the hash character "#" are considered comments, and are ignored.
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaComments may <STRONG>not</STRONG> be included on a line after a
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaconfiguration directive. Blank lines and white space occurring before
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaa directive are ignored, so you may indent directives for clarity.
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<P>You can check your configuration files for syntax errors without
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernastarting the server by using <CODE>apachectl configtest</CODE>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaor the <CODE>-t</CODE> command line option.
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<hr>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<H2><a name="modules">Modules</a></H2>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<table border="1"><tr><td valign="top">
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<strong>Related Modules</strong><br><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<a href="mod/mod_so.html">mod_so</a><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna</td>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<td valign="top">
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<strong>Related Directives</strong><br><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<A HREF="mod/core.html#addmodule">AddModule</A><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<A HREF="mod/core.html#clearmodulelist">ClearModuleList</A><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<A HREF="mod/core.html#ifmodule">&lt;IfModule&gt;</A><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<a href="mod/mod_so.html">LoadModule</a><br>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna</td></tr></table>
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna
a42b70fa75429d73ef00d6ae212676f8a652f51cpquerna<P>Apache is a modular server. This implies that only the most basic
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernafunctionality is included in the core server. Extended features are
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaavailable through <A HREF="mod/index-bytype.html">modules</A> which
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernacan be loaded into Apache. By default, a <A
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaHREF="mod/module-dict.html#Status">base</A> set of modules is
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernaincluded in the server at compile-time. If the server is compiled to
a42b70fa75429d73ef00d6ae212676f8a652f51cpquernause <A HREF="dso.html">dynamically loaded</A> modules, then modules
can be compiled separately and added at any time using the <A
HREF="mod/mod_so.html#loadmodule">LoadModule</A> directive.
Otherwise, Apache must be recompiled to add or remove modules.
Configuration directives may be included conditional on a presence of
a particular module by enclosing them in an <A
HREF="mod/core.html#ifmodule">&lt;IfModule&gt;</A> block.
<P>To see which modules are currently compiled into the server,
you can use the <CODE>-l</CODE> command line option.
<hr>
<H2><a name="scope">Scope of Directives</a></H2>
<table border="1"><tr><td valign="top">
<strong>Related Directives</strong><br><br>
<A HREF="mod/core.html#directory">&lt;Directory&gt;</A><br>
<A HREF="mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</A><br>
<A HREF="mod/core.html#files">&lt;Files&gt;</A><br>
<A HREF="mod/core.html#filesmatch">&lt;FilesMatch&gt;</A><br>
<A HREF="mod/core.html#location">&lt;Location&gt;</A><br>
<A HREF="mod/core.html#locationmatch">&lt;LocationMatch&gt;</A><br>
<a href="mod/core.html#virtualhost">&lt;VirtualHost&gt;</a><br>
</td></tr></table>
<P>Directives placed in the main configuration files apply to the entire
server. If you wish to change the configuration for only a part of
the server, you can scope your directives by placing them in
<CODE><A HREF="mod/core.html#directory">&lt;Directory&gt;</A>,
<A HREF="mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</A>,
<A HREF="mod/core.html#files">&lt;Files&gt;</A>,
<A HREF="mod/core.html#filesmatch">&lt;FilesMatch&gt;</A>,
<A HREF="mod/core.html#location">&lt;Location&gt;</A>,
</CODE> and <CODE>
<A HREF="mod/core.html#locationmatch">&lt;LocationMatch&gt;</A>
</CODE>
sections. These sections limit the application of the directives
which they enclose to particular filesystem locations or URLs. They
can also be nested, allowing for very fine grained configuration.
<P>Apache has the capability to serve many different websites
simultaneously. This is called <A HREF="vhosts/">Virtual Hosting</A>.
Directives can also be scoped by placing them inside
<CODE><A HREF="mod/core.html#virtualhost">&lt;VirtualHost&gt;</A></CODE>
sections, so that they will only apply to requests for a particular
website.
<P>Although most directives can be placed in any of these sections,
some directives do not make sense in some contexts. For example,
directives controlling process creation can only be placed in the main
server context. To find which directives can be placed in which
sections, check the <A
HREF="mod/directive-dict.html#Context">Context</A> of the directive.
For further information, we provide details on <A
HREF="sections.html">How Directory, Location and Files sections
work</A>.
<hr>
<H2><a name="htaccess">.htaccess Files</a></H2>
<table border="1"><tr><td valign="top">
<strong>Related Directives</strong><br><br>
<A HREF="mod/core.html#accessfilename">AccessFileName</A><br>
<A HREF="mod/core.html#allowoverride">AllowOverride</A><br>
</td></tr></table>
<P>Apache allows for decentralized management of configuration via
special files placed inside the web tree. The special files are
usually called <CODE>.htaccess</CODE>, but any name can be specified
in the <A HREF="mod/core.html#accessfilename"><CODE
>AccessFileName</CODE></A> directive. Directives placed in
<CODE>.htaccess</CODE> files apply to the directory where you place
the file, and all sub-directories. The <CODE>.htaccess</CODE> files
follow the same syntax as the main configuration files. Since
<CODE>.htaccess</CODE> files are read on every request, changes made
in these files take immediate effect.
<P>To find which directives can be placed in <CODE>.htaccess</CODE>
files, check the <A HREF="mod/directive-dict.html#Context">Context</A>
of the directive. The server administrator further controls what
directives may be placed in <CODE>.htaccess</CODE> files by
configuring the <A
HREF="mod/core.html#allowoverride"><CODE>AllowOverride</CODE></A>
directive in the main configuration files.
<hr>
<H2><a name="logs">Log files</a></H2>
<!-- XXX: This section should be moved to its own file -->
<H3>security warning</H3>
Anyone who can write to the directory where Apache is writing a
log file can almost certainly gain access to the uid that the server is
started as, which is normally root. Do <EM>NOT</EM> give people write
access to the directory the logs are stored in without being aware of
the consequences; see the <A HREF="misc/security_tips.html">security tips</A>
document for details.
<H3>pid file</H3>
<P>On startup, Apache saves the process id of the parent httpd process to
the file <CODE>logs/httpd.pid</CODE>. This filename can be changed
with the <A HREF="mod/core.html#pidfile">PidFile</A> directive. The
process-id is for use by the administrator in restarting and
terminating the daemon: on Unix, a HUP or USR1 signal causes the
daemon to re-read its configuration files and a TERM signal causes it
to die gracefully; on Windows, use the -k command line option instead.
For more information see the <A HREF="stopping.html">Stopping and
Restarting</A> page.
<P>
If the process dies (or is killed) abnormally, then it will be necessary to
kill the children httpd processes.
<H3>Error log</H3>
<P>The server will log error messages to a log file, by default
<CODE>logs/error_log</CODE> on Unix or <CODE>logs/error.log</CODE> on
Windows and OS/2. The filename can be set using the <A
HREF="mod/core.html#errorlog">ErrorLog</A> directive; different error
logs can be set for different <A
HREF="mod/core.html#virtualhost">virtual hosts</A>.
<H3>Transfer log</H3>
<P>The server will typically log each request to a transfer file, by
default <CODE>logs/access_log</CODE> on Unix or
<CODE>logs/access.log</CODE> on Windows and OS/2. The filename can be
set using a <A HREF="mod/mod_log_config.html#customlog">CustomLog</A>
directive; different transfer logs can be set for different <A
HREF="mod/core.html#virtualhost">virtual hosts</A>.
<!--#include virtual="footer.html" -->
</BODY>
</HTML>