]> granicus.if.org Git - apache/blob - docs/manual/configuring.xml
Add PR reference and docs for -DDUMP_CONFIG
[apache] / docs / manual / configuring.xml
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$ -->
5
6 <!--
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
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
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.
21 -->
22
23 <manualpage metafile="configuring.xml.meta">
24
25   <title>Configuration Files</title>
26
27 <summary>
28 <p>This document describes the files used to configure Apache HTTP
29 Server.</p>
30 </summary>
31
32   <section id="main">
33     <title>Main Configuration Files</title>
34     <related>
35       <modulelist>
36         <module>mod_mime</module>
37       </modulelist>
38       <directivelist>
39         <directive module="core" type="section">IfDefine</directive>
40         <directive module="core">Include</directive>
41         <directive module="mod_mime">TypesConfig</directive>
42       </directivelist>
43     </related>
44
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>
56
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>
61   </section>
62
63   <section id="syntax">
64     <title>Syntax of the Configuration Files</title>
65
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>
71
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>
79
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>
92
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>
98
99     <p>The maximum length of a line in the configuration file, after
100     variable substitution, joining any continued lines and removing leading
101     and trailing white space, is 8192 characters.</p>
102
103     <p>You can check your configuration files for syntax errors
104     without starting the server by using <code>apachectl
105     configtest</code> or the <code>-t</code> command line
106     option.</p>
107
108     <p>You can use <module>mod_info</module>'s <code>-DDUMP_CONFIG</code> to
109     dump the configuration with all included files and environment
110     variables resolved and all comments and non-matching
111     <directive module="core" type="section">IfDefine</directive> and
112     <directive module="core" type="section">IfModule</directive> sections
113     removed.</p>
114   </section>
115
116   <section id="modules">
117     <title>Modules</title>
118
119     <related>
120       <modulelist>
121         <module>mod_so</module>
122       </modulelist>
123       <directivelist>
124         <directive module="core" type="section">IfModule</directive>
125         <directive module="mod_so">LoadModule</directive>
126       </directivelist>
127     </related>
128
129     <p>httpd is a modular server. This implies that only the most
130     basic functionality is included in the core server. Extended
131     features are available through <a
132     href="mod/">modules</a> which can be loaded
133     into httpd. By default, a <a
134     href="mod/module-dict.html#Status">base</a> set of modules is
135     included in the server at compile-time. If the server is
136     compiled to use <a href="dso.html">dynamically loaded</a>
137     modules, then modules can be compiled separately and added at
138     any time using the <directive module="mod_so">LoadModule</directive>
139     directive.
140     Otherwise, httpd must be recompiled to add or remove modules.
141     Configuration directives may be included conditional on a
142     presence of a particular module by enclosing them in an <directive
143     module="core" type="section">IfModule</directive> block. However,
144     <directive type="section">IfModule</directive> blocks are not
145     required, and in some cases may mask the fact that you're missing an
146     important module.</p>
147
148     <p>To see which modules are currently compiled into the server,
149     you can use the <code>-l</code> command line option. You can also
150     see what modules are loaded dynamically using the <code>-M</code>
151     command line option.</p>
152   </section>
153
154   <section id="scope">
155     <title>Scope of Directives</title>
156
157     <related>
158       <directivelist>
159         <directive module="core" type="section">Directory</directive>
160         <directive module="core" type="section">DirectoryMatch</directive>
161         <directive module="core" type="section">Files</directive>
162         <directive module="core" type="section">FilesMatch</directive>
163         <directive module="core" type="section">Location</directive>
164         <directive module="core" type="section">LocationMatch</directive>
165         <directive module="core" type="section">VirtualHost</directive>
166       </directivelist>
167     </related>
168
169     <p>Directives placed in the main configuration files apply to
170     the entire server. If you wish to change the configuration for
171     only a part of the server, you can scope your directives by
172     placing them in <directive module="core"
173     type="section">Directory</directive>, <directive module="core"
174     type="section">DirectoryMatch</directive>, <directive module="core"
175     type="section">Files</directive>, <directive module="core"
176     type="section">FilesMatch</directive>, <directive module="core"
177     type="section">Location</directive>, and <directive module="core"
178     type="section">LocationMatch</directive>
179     sections. These sections limit the application of the
180     directives which they enclose to particular filesystem
181     locations or URLs. They can also be nested, allowing for very
182     fine grained configuration.</p>
183
184     <p>httpd has the capability to serve many different websites
185     simultaneously. This is called <a href="vhosts/">Virtual
186     Hosting</a>. Directives can also be scoped by placing them
187     inside <directive module="core" type="section">VirtualHost</directive>
188     sections, so that they will only apply to requests for a
189     particular website.</p>
190
191     <p>Although most directives can be placed in any of these
192     sections, some directives do not make sense in some contexts.
193     For example, directives controlling process creation can only
194     be placed in the main server context. To find which directives
195     can be placed in which sections, check the <a
196     href="mod/directive-dict.html#Context">Context</a> of the
197     directive. For further information, we provide details on <a
198     href="sections.html">How Directory, Location and Files sections
199     work</a>.</p>
200   </section>
201
202   <section id="htaccess">
203     <title>.htaccess Files</title>
204
205     <related>
206       <directivelist>
207         <directive module="core">AccessFileName</directive>
208         <directive module="core">AllowOverride</directive>
209       </directivelist>
210     </related>
211
212     <p>httpd allows for decentralized management of configuration
213     via special files placed inside the web tree. The special files
214     are usually called <code>.htaccess</code>, but any name can be
215     specified in the <directive module="core">AccessFileName</directive>
216     directive. Directives placed in <code>.htaccess</code> files
217     apply to the directory where you place the file, and all
218     sub-directories. The <code>.htaccess</code> files follow the
219     same syntax as the main configuration files. Since
220     <code>.htaccess</code> files are read on every request, changes
221     made in these files take immediate effect.</p>
222
223     <p>To find which directives can be placed in
224     <code>.htaccess</code> files, check the <a
225     href="mod/directive-dict.html#Context">Context</a> of the
226     directive. The server administrator further controls what
227     directives may be placed in <code>.htaccess</code> files by
228     configuring the <directive module="core">AllowOverride</directive>
229     directive in the main configuration files.</p>
230
231     <p>For more information on <code>.htaccess</code> files, see
232     the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>
233   </section>
234 </manualpage>