configuring.html revision 78d93899951a86bdf61c7e13cbbde67d8af199bb
1261N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
970N/A<HTML>
970N/A<HEAD>
970N/A<TITLE>Configuring Apache</TITLE>
970N/A</HEAD>
970N/A
970N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
970N/A<BODY
970N/A BGCOLOR="#FFFFFF"
970N/A TEXT="#000000"
970N/A LINK="#0000FF"
970N/A VLINK="#000080"
970N/A ALINK="#FF0000"
970N/A>
970N/A<!--#include virtual="header.html" -->
970N/A<H1 ALIGN="CENTER">Configuring Apache</H1>
970N/A
970N/A<H2>Main Configuration Files</H2>
970N/A
970N/A<P>Apache is configured by placing <A HREF="mod/directives.html"
970N/A>directives</A> in plain text configuration files. The main
970N/Aconfiguration file is usually called <CODE>httpd.conf</CODE>. The
1207N/Alocation of this file is set at compile-time, but may be overridden
970N/Awith the <CODE>-f</CODE> command line flag. Some sites also have
970N/A<CODE>srm.conf</CODE> and <CODE>access.conf</CODE> files for <A
970N/AHREF="http://www.apache.org/info/three-config-files.html">historical
982N/Areasons</A>. In addition, other configuration files may be added using
982N/Athe <CODE><A HREF="mod/core.html#include">Include</A></CODE>
982N/Adirective. Any directive may be placed in any of these configuration
1153N/Afiles. Changes to the main configuration files are only recognized by
982N/AApache when it is started or restarted.
1261N/A
1261N/A<P>
1261N/AThe server also reads a file containing mime document types; the
1261N/Afilename is set by the <A HREF="mod/mod_mime.html#typesconfig"
1261N/A>TypesConfig</A> directive, and is <CODE>mime.types</CODE> by default.
1261N/A
1261N/A<H2>Syntax of the Configuration Files</H2>
1261N/A
1261N/A<P>Directives in the configuration files are case-insensitive, but
1261N/Aarguments to directives are often case sensitive. Lines which begin
1261N/Awith the hash character "#" are considered comments, and are ignored.
970N/AComments may <STRONG>not</STRONG> be included on a line after a configuration
1261N/Adirective. White space occurring before a directive
1261N/Ais ignored, so you may indent directives for clarity.
1207N/A
970N/A<P>You can check your configuration files for syntax errors without
1169N/Astarting the server by using <CODE>apachectl configtest</CODE>
1207N/Aor the <CODE>-t</CODE> command line option.
1207N/A
1207N/A<H2>Modules</H2>
1207N/A
1169N/A<P>Apache is a modular server. This implies that only the most basic
1169N/Afunctionality is included in the core server. Extended features are
1207N/Aavailable through <A HREF="mod/index-bytype.html">modules</A> which can
1169N/Abe loaded into Apache. By default, a <A
1169N/AHREF="mod/directive-dict.html#Status">base</A> set of modules is
1207N/Aincluded in the server at compile-time. If the server is compiled to
970N/Ause <A HREF="dso.html">dynamically loaded</A> modules, then modules
970N/Acan be compiled separately and added at any time using the <A
1207N/AHREF="mod/mod_so.html#loadmodule">LoadModule</A> directive.
1207N/AOtherwise, apache must be recompiled to add or remove modules.
970N/A
970N/A<P>To see which modules are currently compiled into the server,
1207N/Ayou can use the <CODE>-l</CODE> command line option.
970N/A
1123N/A<H2>Scope of Directives</H2>
1207N/A
970N/A<P>Directives placed in the main configuration files apply to the entire
970N/Aserver. If you wish to change the configuration for only a part of
1207N/Athe server, you can scope your directives by placing them in
970N/A<CODE><A HREF="mod/core.html#directory">&lt;Directory&gt;</A>,
970N/A<A HREF="mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</A>,
1207N/A<A HREF="mod/core.html#files">&lt;Files&gt;</A>,
970N/A<A HREF="mod/core.html#filesmatch">&lt;FilesMatch&gt;</A>,
970N/A<A HREF="mod/core.html#location">&lt;Location&gt;</A>,
1207N/A</CODE> and <CODE>
970N/A<A HREF="mod/core.html#locationmatch">&lt;LocationMatch&gt;</A>
970N/A</CODE>
1207N/Asections. These sections limit the application of the directives
1207N/Awhich they enclose to particular filesystem locations or URLs. They
970N/Acan also be nested, allowing for very fine grained configuration.
970N/A
1207N/A<P>Apache has the capability to serve many different websites
970N/Asimultaneously. This is called <A HREF="vhosts/">Virtual Hosting</A>.
970N/ADirectives can also be scoped by placing them inside
1207N/A<CODE><A HREF="mod/core.html#virtualhost">&lt;VirtualHost&gt;</A></CODE>
970N/Asections, so that they will only apply to requests for a particular
970N/Awebsite.
1207N/A
970N/A<P>Although most directives can be placed in any of these sections,
1123N/Asome directives do not make sense in some contexts. For example,
1207N/Adirectives controlling process creation can only be placed in the main
1123N/Aserver context. To find which directives can be placed in which
970N/Asections, check the <A
1207N/AHREF="mod/directive-dict.html#Context">Context</A> of the directive.
970N/AFor further information, we provide details on <A
1123N/AHREF="sections.html">How Directory, Location and Files sections
1207N/Awork</A>.
970N/A
970N/A<H2>.htaccess Files</H2>
1207N/A
970N/A<P>Apache allows for decentralized management of configuration via
1123N/Aspecial files placed inside the web tree. The special files are
1123N/Ausually called <CODE>.htaccess</CODE>, but any name can be specified
1207N/Ain the <A HREF="mod/core.html#accessfilename"><CODE
1123N/A>AccessFileName</CODE></A> directive. Directives placed in
970N/A<CODE>.htaccess</CODE> files apply to the directory where you place
1207N/Athe file, and all sub-directories. The <CODE>.htaccess</CODE> files
970N/Afollow the same syntax as the main configuration files. Since
970N/A<CODE>.htaccess</CODE> files are read on every request, rather than
1207N/Aonly at server startup, changes made in these files take immediate
970N/Aeffect.
1169N/A
1207N/A<P>To find which directives can be placed in <CODE>.htaccess</CODE>
970N/Afiles, check the <A HREF="mod/directive-dict.html#Context">Context</A>
1169N/Aof the directive. The server administrator further controls what
1207N/Adirectives may be placed in <CODE>.htaccess</CODE> files by
1207N/Aconfiguring the <A
1169N/AHREF="mod/core.html#allowoverride"><CODE>AllowOverride</CODE></A>
1169N/Adirective in the main configuration files.
1261N/A
1261N/A<H2>Log files</H2>
1169N/A<H3>security warning</H3>
970N/AAnyone who can write to the directory where Apache is writing a
1261N/Alog file can almost certainly gain access to the uid that the server is
1261N/Astarted as, which is normally root. Do <EM>NOT</EM> give people write
970N/Aaccess to the directory the logs are stored in without being aware of
970N/Athe consequences; see the <A HREF="misc/security_tips.html">security tips</A>
1261N/Adocument for details.
1261N/A
970N/A<H3>pid file</H3>
970N/A
1261N/A<P>On startup, Apache saves the process id of the parent httpd process to
1261N/Athe file <CODE>logs/httpd.pid</CODE>. This filename can be changed
970N/Awith the <A HREF="mod/core.html#pidfile">PidFile</A> directive. The
970N/Aprocess-id is for use by the administrator in restarting and
1261N/Aterminating the daemon: on Unix, a HUP or USR1 signal causes the
1261N/Adaemon to re-read its configuration files and a TERM signal causes it
1261N/Ato die gracefully; on Windows, use the -k command line option instead.
1261N/AFor more information see the <A HREF="stopping.html">Stopping and
1261N/ARestarting</A> page.
1261N/A
970N/A<P>
1169N/AIf the process dies (or is killed) abnormally, then it will be necessary to
1207N/Akill the children httpd processes.
1169N/A
1169N/A<H3>Error log</H3>
1207N/A
1169N/A<P>The server will log error messages to a log file, by default
970N/A<CODE>logs/error_log</CODE> on Unix or <CODE>logs/error.log</CODE> on
1261N/AWindows and OS/2. The filename can be set using the <A
1261N/AHREF="mod/core.html#errorlog">ErrorLog</A> directive; different error
970N/Alogs can be set for different <A
970N/AHREF="mod/core.html#virtualhost">virtual hosts</A>.
1207N/A
970N/A<H3>Transfer log</H3>
1130N/A
1207N/A<P>The server will typically log each request to a transfer file, by
1130N/Adefault <CODE>logs/access_log</CODE> on Unix or
1169N/A<CODE>logs/access.log</CODE> on Windows and OS/2. The filename can be
1261N/Aset using a <A HREF="mod/mod_log_config.html#customlog">CustomLog</A>
1261N/Adirective; different transfer logs can be set for different <A
970N/AHREF="mod/core.html#virtualhost">virtual hosts</A>.
1261N/A
1261N/A
1261N/A<!--#include virtual="footer.html" -->
970N/A</BODY>
1132N/A</HTML>
1207N/A