]> granicus.if.org Git - apache/blob - docs/manual/configuring.xml
Help doc writer to spot places where:
[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>Arguments to directives are separated by whitespace. If an
73     argument contains spaces, you must enclose that argument in quotes.</p>
74
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 the same line as a configuration directive.
80     White space occurring before a directive is ignored, so
81     you may indent directives for clarity. Blank lines are also ignored.</p>
82
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>
95
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>
101
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>
106
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
110     option.</p>
111
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>
119   </section>
120
121   <section id="modules">
122     <title>Modules</title>
123
124     <related>
125       <modulelist>
126         <module>mod_so</module>
127       </modulelist>
128       <directivelist>
129         <directive module="core" type="section">IfModule</directive>
130         <directive module="mod_so">LoadModule</directive>
131       </directivelist>
132     </related>
133
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>
144     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>
152
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>
157   </section>
158
159   <section id="scope">
160     <title>Scope of Directives</title>
161
162     <related>
163       <directivelist>
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>
171       </directivelist>
172     </related>
173
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>
188
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>
195
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
204     work</a>.</p>
205   </section>
206
207   <section id="htaccess">
208     <title>.htaccess Files</title>
209
210     <related>
211       <directivelist>
212         <directive module="core">AccessFileName</directive>
213         <directive module="core">AllowOverride</directive>
214       </directivelist>
215     </related>
216
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>
227
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>
235
236     <p>For more information on <code>.htaccess</code> files, see
237     the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>
238   </section>
239 </manualpage>