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>You can check your configuration files for syntax errors
100 without starting the server by using <code>apachectl
101 configtest</code> or the <code>-t</code> command line
104 <p>You can use <module>mod_info</module>'s <code>-DDUMP_CONFIG</code> to
105 dump the configuration with all included files and environment
106 variables resolved and all comments and non-matching
107 <directive module="core" type="section">IfDefine</directive> and
108 <directive module="core" type="section">IfModule</directive> sections
112 <section id="modules">
113 <title>Modules</title>
117 <module>mod_so</module>
120 <directive module="core" type="section">IfModule</directive>
121 <directive module="mod_so">LoadModule</directive>
125 <p>httpd is a modular server. This implies that only the most
126 basic functionality is included in the core server. Extended
127 features are available through <a
128 href="mod/">modules</a> which can be loaded
129 into httpd. By default, a <a
130 href="mod/module-dict.html#Status">base</a> set of modules is
131 included in the server at compile-time. If the server is
132 compiled to use <a href="dso.html">dynamically loaded</a>
133 modules, then modules can be compiled separately and added at
134 any time using the <directive module="mod_so">LoadModule</directive>
136 Otherwise, httpd must be recompiled to add or remove modules.
137 Configuration directives may be included conditional on a
138 presence of a particular module by enclosing them in an <directive
139 module="core" type="section">IfModule</directive> block. However,
140 <directive type="section">IfModule</directive> blocks are not
141 required, and in some cases may mask the fact that you're missing an
142 important module.</p>
144 <p>To see which modules are currently compiled into the server,
145 you can use the <code>-l</code> command line option. You can also
146 see what modules are loaded dynamically using the <code>-M</code>
147 command line option.</p>
151 <title>Scope of Directives</title>
155 <directive module="core" type="section">Directory</directive>
156 <directive module="core" type="section">DirectoryMatch</directive>
157 <directive module="core" type="section">Files</directive>
158 <directive module="core" type="section">FilesMatch</directive>
159 <directive module="core" type="section">Location</directive>
160 <directive module="core" type="section">LocationMatch</directive>
161 <directive module="core" type="section">VirtualHost</directive>
165 <p>Directives placed in the main configuration files apply to
166 the entire server. If you wish to change the configuration for
167 only a part of the server, you can scope your directives by
168 placing them in <directive module="core"
169 type="section">Directory</directive>, <directive module="core"
170 type="section">DirectoryMatch</directive>, <directive module="core"
171 type="section">Files</directive>, <directive module="core"
172 type="section">FilesMatch</directive>, <directive module="core"
173 type="section">Location</directive>, and <directive module="core"
174 type="section">LocationMatch</directive>
175 sections. These sections limit the application of the
176 directives which they enclose to particular filesystem
177 locations or URLs. They can also be nested, allowing for very
178 fine grained configuration.</p>
180 <p>httpd has the capability to serve many different websites
181 simultaneously. This is called <a href="vhosts/">Virtual
182 Hosting</a>. Directives can also be scoped by placing them
183 inside <directive module="core" type="section">VirtualHost</directive>
184 sections, so that they will only apply to requests for a
185 particular website.</p>
187 <p>Although most directives can be placed in any of these
188 sections, some directives do not make sense in some contexts.
189 For example, directives controlling process creation can only
190 be placed in the main server context. To find which directives
191 can be placed in which sections, check the <a
192 href="mod/directive-dict.html#Context">Context</a> of the
193 directive. For further information, we provide details on <a
194 href="sections.html">How Directory, Location and Files sections
198 <section id="htaccess">
199 <title>.htaccess Files</title>
203 <directive module="core">AccessFileName</directive>
204 <directive module="core">AllowOverride</directive>
208 <p>httpd allows for decentralized management of configuration
209 via special files placed inside the web tree. The special files
210 are usually called <code>.htaccess</code>, but any name can be
211 specified in the <directive module="core">AccessFileName</directive>
212 directive. Directives placed in <code>.htaccess</code> files
213 apply to the directory where you place the file, and all
214 sub-directories. The <code>.htaccess</code> files follow the
215 same syntax as the main configuration files. Since
216 <code>.htaccess</code> files are read on every request, changes
217 made in these files take immediate effect.</p>
219 <p>To find which directives can be placed in
220 <code>.htaccess</code> files, check the <a
221 href="mod/directive-dict.html#Context">Context</a> of the
222 directive. The server administrator further controls what
223 directives may be placed in <code>.htaccess</code> files by
224 configuring the <directive module="core">AllowOverride</directive>
225 directive in the main configuration files.</p>
227 <p>For more information on <code>.htaccess</code> files, see
228 the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>