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>Arguments to directives are separated by whitespace. If an
73 argument contains spaces, you must enclose that argument in quotes.</p>
75 <p>Directives in the configuration files are case-insensitive,
76 but arguments to directives are often case sensitive. Lines
77 that begin with the hash character "#" are considered
78 comments, and are ignored. Comments may <strong>not</strong> be
79 included on a line after a configuration directive. Blank lines
80 and white space occurring before a directive are ignored, so
81 you may indent directives for clarity.</p>
83 <p>The values of variables defined with the <directive
84 module="core">Define</directive> of or shell environment variables can
85 be used in configuration file lines using the syntax <code>${VAR}</code>.
86 If "VAR" is the name of a valid variable, the value of that variable is
87 substituted into that spot in the configuration file line, and processing
88 continues as if that text were found directly in the configuration file.
89 Variables defined with <directive module="core">Define</directive> take
90 precedence over shell environment variables.
91 If the "VAR" variable is not found, the characters <code>${VAR}</code>
92 are left unchanged, and a warning is logged.
93 Variable names may not contain colon ":" characters, to avoid clashes with
94 <directive module="mod_rewrite">RewriteMap</directive>'s syntax.</p>
96 <p>Only shell environment variables defined before the server is started
97 can be used in expansions. Environment variables defined in the
98 configuration file itself, for example with <directive
99 module="mod_env">SetEnv</directive>, take effect too late to be used for
100 expansions in the configuration file.</p>
102 <p>The maximum length of a line in normal configuration files, after
103 variable substitution and joining any continued lines, is approximately
104 16 MiB. In <a href="configuring.html#htaccess">.htaccess files</a>, the
105 maximum length is 8190 characters.</p>
107 <p>You can check your configuration files for syntax errors
108 without starting the server by using <code>apachectl
109 configtest</code> or the <code>-t</code> command line
112 <p>You can use <module>mod_info</module>'s <code>-DDUMP_CONFIG</code> to
113 dump the configuration with all included files and environment
114 variables resolved and all comments and non-matching
115 <directive module="core" type="section">IfDefine</directive> and
116 <directive module="core" type="section">IfModule</directive> sections
117 removed. However, the output does not reflect the merging or overriding
118 that may happen for repeated directives.</p>
121 <section id="modules">
122 <title>Modules</title>
126 <module>mod_so</module>
129 <directive module="core" type="section">IfModule</directive>
130 <directive module="mod_so">LoadModule</directive>
134 <p>httpd is a modular server. This implies that only the most
135 basic functionality is included in the core server. Extended
136 features are available through <a
137 href="mod/">modules</a> which can be loaded
138 into httpd. By default, a <a
139 href="mod/module-dict.html#Status">base</a> set of modules is
140 included in the server at compile-time. If the server is
141 compiled to use <a href="dso.html">dynamically loaded</a>
142 modules, then modules can be compiled separately and added at
143 any time using the <directive module="mod_so">LoadModule</directive>
145 Otherwise, httpd must be recompiled to add or remove modules.
146 Configuration directives may be included conditional on a
147 presence of a particular module by enclosing them in an <directive
148 module="core" type="section">IfModule</directive> block. However,
149 <directive type="section">IfModule</directive> blocks are not
150 required, and in some cases may mask the fact that you're missing an
151 important module.</p>
153 <p>To see which modules are currently compiled into the server,
154 you can use the <code>-l</code> command line option. You can also
155 see what modules are loaded dynamically using the <code>-M</code>
156 command line option.</p>
160 <title>Scope of Directives</title>
164 <directive module="core" type="section">Directory</directive>
165 <directive module="core" type="section">DirectoryMatch</directive>
166 <directive module="core" type="section">Files</directive>
167 <directive module="core" type="section">FilesMatch</directive>
168 <directive module="core" type="section">Location</directive>
169 <directive module="core" type="section">LocationMatch</directive>
170 <directive module="core" type="section">VirtualHost</directive>
174 <p>Directives placed in the main configuration files apply to
175 the entire server. If you wish to change the configuration for
176 only a part of the server, you can scope your directives by
177 placing them in <directive module="core"
178 type="section">Directory</directive>, <directive module="core"
179 type="section">DirectoryMatch</directive>, <directive module="core"
180 type="section">Files</directive>, <directive module="core"
181 type="section">FilesMatch</directive>, <directive module="core"
182 type="section">Location</directive>, and <directive module="core"
183 type="section">LocationMatch</directive>
184 sections. These sections limit the application of the
185 directives which they enclose to particular filesystem
186 locations or URLs. They can also be nested, allowing for very
187 fine grained configuration.</p>
189 <p>httpd has the capability to serve many different websites
190 simultaneously. This is called <a href="vhosts/">Virtual
191 Hosting</a>. Directives can also be scoped by placing them
192 inside <directive module="core" type="section">VirtualHost</directive>
193 sections, so that they will only apply to requests for a
194 particular website.</p>
196 <p>Although most directives can be placed in any of these
197 sections, some directives do not make sense in some contexts.
198 For example, directives controlling process creation can only
199 be placed in the main server context. To find which directives
200 can be placed in which sections, check the <a
201 href="mod/directive-dict.html#Context">Context</a> of the
202 directive. For further information, we provide details on <a
203 href="sections.html">How Directory, Location and Files sections
207 <section id="htaccess">
208 <title>.htaccess Files</title>
212 <directive module="core">AccessFileName</directive>
213 <directive module="core">AllowOverride</directive>
217 <p>httpd allows for decentralized management of configuration
218 via special files placed inside the web tree. The special files
219 are usually called <code>.htaccess</code>, but any name can be
220 specified in the <directive module="core">AccessFileName</directive>
221 directive. Directives placed in <code>.htaccess</code> files
222 apply to the directory where you place the file, and all
223 sub-directories. The <code>.htaccess</code> files follow the
224 same syntax as the main configuration files. Since
225 <code>.htaccess</code> files are read on every request, changes
226 made in these files take immediate effect.</p>
228 <p>To find which directives can be placed in
229 <code>.htaccess</code> files, check the <a
230 href="mod/directive-dict.html#Context">Context</a> of the
231 directive. The server administrator further controls what
232 directives may be placed in <code>.htaccess</code> files by
233 configuring the <directive module="core">AllowOverride</directive>
234 directive in the main configuration files.</p>
236 <p>For more information on <code>.htaccess</code> files, see
237 the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>