1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <manualpage metafile="configuring.xml.meta">
25 <title>Configuration Files</title>
28 <p>This document describes the files used to configure Apache HTTP
33 <title>Main Configuration Files</title>
36 <module>mod_mime</module>
39 <directive module="core" type="section">IfDefine</directive>
40 <directive module="core">Include</directive>
41 <directive module="mod_mime">TypesConfig</directive>
45 <p>Apache HTTP Server is configured by placing <a
46 href="mod/directives.html">directives</a> in plain text
47 configuration files. The main configuration file is usually called
48 <code>httpd.conf</code>. The location of this file is set at
49 compile-time, but may be overridden with the <code>-f</code>
50 command line flag. In addition, other configuration files may be
51 added using the <directive module="core">Include</directive>
52 directive, and wildcards can be used to include many configuration
53 files. Any directive may be placed in any of these configuration
54 files. Changes to the main configuration files are only
55 recognized by httpd when it is started or restarted.</p>
57 <p>The server also reads a file containing mime document types;
58 the filename is set by the <directive
59 module="mod_mime">TypesConfig</directive> directive,
60 and is <code>mime.types</code> by default.</p>
64 <title>Syntax of the Configuration Files</title>
66 <p>httpd configuration files contain one directive per line.
67 The backslash "\" may be used as the last character on a line
68 to indicate that the directive continues onto the next line.
69 There must be no other characters or white space between the
70 backslash and the end of the line.</p>
72 <p>Directives in the configuration files are case-insensitive,
73 but arguments to directives are often case sensitive. Lines
74 that begin with the hash character "#" are considered
75 comments, and are ignored. Comments may <strong>not</strong> be
76 included on a line after a configuration directive. Blank lines
77 and white space occurring before a directive are ignored, so
78 you may indent directives for clarity.</p>
80 <p>The values of variables defined with the <directive
81 module="core">Define</directive> of or shell environment variables can
82 be used in configuration file lines using the syntax <code>${VAR}</code>.
83 If "VAR" is the name of a valid variable, the value of that variable is
84 substituted into that spot in the configuration file line, and processing
85 continues as if that text were found directly in the configuration file.
86 Variables defined with <directive module="core">Define</directive> take
87 precedence over shell environment variables.
88 If the "VAR" variable is not found, the characters <code>${VAR}</code>
89 are left unchanged, and a warning is logged.
90 Variable names may not contain colon ":" characters, to avoid clashes with
91 <directive module="mod_rewrite">RewriteMap</directive>'s syntax.</p>
93 <p>Only shell environment variables defined before the server is started
94 can be used in expansions. Environment variables defined in the
95 configuration file itself, for example with <directive
96 module="mod_env">SetEnv</directive>, take effect too late to be used for
97 expansions in the configuration file.</p>
99 <p>The maximum length of a line in normal configuration files, after
100 variable substitution and joining any continued lines, is approximately
101 16 MiB. In <a href="configuring.xml#htaccess">.htaccess files</a>, the
102 maximum length is 8190 characters.</p>
104 <p>You can check your configuration files for syntax errors
105 without starting the server by using <code>apachectl
106 configtest</code> or the <code>-t</code> command line
109 <p>You can use <module>mod_info</module>'s <code>-DDUMP_CONFIG</code> to
110 dump the configuration with all included files and environment
111 variables resolved and all comments and non-matching
112 <directive module="core" type="section">IfDefine</directive> and
113 <directive module="core" type="section">IfModule</directive> sections
114 removed. However, the output does not reflect the merging or overriding
115 that may happen for repeated directives.</p>
118 <section id="modules">
119 <title>Modules</title>
123 <module>mod_so</module>
126 <directive module="core" type="section">IfModule</directive>
127 <directive module="mod_so">LoadModule</directive>
131 <p>httpd is a modular server. This implies that only the most
132 basic functionality is included in the core server. Extended
133 features are available through <a
134 href="mod/">modules</a> which can be loaded
135 into httpd. By default, a <a
136 href="mod/module-dict.html#Status">base</a> set of modules is
137 included in the server at compile-time. If the server is
138 compiled to use <a href="dso.html">dynamically loaded</a>
139 modules, then modules can be compiled separately and added at
140 any time using the <directive module="mod_so">LoadModule</directive>
142 Otherwise, httpd must be recompiled to add or remove modules.
143 Configuration directives may be included conditional on a
144 presence of a particular module by enclosing them in an <directive
145 module="core" type="section">IfModule</directive> block. However,
146 <directive type="section">IfModule</directive> blocks are not
147 required, and in some cases may mask the fact that you're missing an
148 important module.</p>
150 <p>To see which modules are currently compiled into the server,
151 you can use the <code>-l</code> command line option. You can also
152 see what modules are loaded dynamically using the <code>-M</code>
153 command line option.</p>
157 <title>Scope of Directives</title>
161 <directive module="core" type="section">Directory</directive>
162 <directive module="core" type="section">DirectoryMatch</directive>
163 <directive module="core" type="section">Files</directive>
164 <directive module="core" type="section">FilesMatch</directive>
165 <directive module="core" type="section">Location</directive>
166 <directive module="core" type="section">LocationMatch</directive>
167 <directive module="core" type="section">VirtualHost</directive>
171 <p>Directives placed in the main configuration files apply to
172 the entire server. If you wish to change the configuration for
173 only a part of the server, you can scope your directives by
174 placing them in <directive module="core"
175 type="section">Directory</directive>, <directive module="core"
176 type="section">DirectoryMatch</directive>, <directive module="core"
177 type="section">Files</directive>, <directive module="core"
178 type="section">FilesMatch</directive>, <directive module="core"
179 type="section">Location</directive>, and <directive module="core"
180 type="section">LocationMatch</directive>
181 sections. These sections limit the application of the
182 directives which they enclose to particular filesystem
183 locations or URLs. They can also be nested, allowing for very
184 fine grained configuration.</p>
186 <p>httpd has the capability to serve many different websites
187 simultaneously. This is called <a href="vhosts/">Virtual
188 Hosting</a>. Directives can also be scoped by placing them
189 inside <directive module="core" type="section">VirtualHost</directive>
190 sections, so that they will only apply to requests for a
191 particular website.</p>
193 <p>Although most directives can be placed in any of these
194 sections, some directives do not make sense in some contexts.
195 For example, directives controlling process creation can only
196 be placed in the main server context. To find which directives
197 can be placed in which sections, check the <a
198 href="mod/directive-dict.html#Context">Context</a> of the
199 directive. For further information, we provide details on <a
200 href="sections.html">How Directory, Location and Files sections
204 <section id="htaccess">
205 <title>.htaccess Files</title>
209 <directive module="core">AccessFileName</directive>
210 <directive module="core">AllowOverride</directive>
214 <p>httpd allows for decentralized management of configuration
215 via special files placed inside the web tree. The special files
216 are usually called <code>.htaccess</code>, but any name can be
217 specified in the <directive module="core">AccessFileName</directive>
218 directive. Directives placed in <code>.htaccess</code> files
219 apply to the directory where you place the file, and all
220 sub-directories. The <code>.htaccess</code> files follow the
221 same syntax as the main configuration files. Since
222 <code>.htaccess</code> files are read on every request, changes
223 made in these files take immediate effect.</p>
225 <p>To find which directives can be placed in
226 <code>.htaccess</code> files, check the <a
227 href="mod/directive-dict.html#Context">Context</a> of the
228 directive. The server administrator further controls what
229 directives may be placed in <code>.htaccess</code> files by
230 configuring the <directive module="core">AllowOverride</directive>
231 directive in the main configuration files.</p>
233 <p>For more information on <code>.htaccess</code> files, see
234 the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>