]> granicus.if.org Git - apache/blob - docs/manual/configuring.xml
update transformation
[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 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>
103
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
107     option.</p>
108
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.</p>
115   </section>
116
117   <section id="modules">
118     <title>Modules</title>
119
120     <related>
121       <modulelist>
122         <module>mod_so</module>
123       </modulelist>
124       <directivelist>
125         <directive module="core" type="section">IfModule</directive>
126         <directive module="mod_so">LoadModule</directive>
127       </directivelist>
128     </related>
129
130     <p>httpd is a modular server. This implies that only the most
131     basic functionality is included in the core server. Extended
132     features are available through <a
133     href="mod/">modules</a> which can be loaded
134     into httpd. By default, a <a
135     href="mod/module-dict.html#Status">base</a> set of modules is
136     included in the server at compile-time. If the server is
137     compiled to use <a href="dso.html">dynamically loaded</a>
138     modules, then modules can be compiled separately and added at
139     any time using the <directive module="mod_so">LoadModule</directive>
140     directive.
141     Otherwise, httpd must be recompiled to add or remove modules.
142     Configuration directives may be included conditional on a
143     presence of a particular module by enclosing them in an <directive
144     module="core" type="section">IfModule</directive> block. However,
145     <directive type="section">IfModule</directive> blocks are not
146     required, and in some cases may mask the fact that you're missing an
147     important module.</p>
148
149     <p>To see which modules are currently compiled into the server,
150     you can use the <code>-l</code> command line option. You can also
151     see what modules are loaded dynamically using the <code>-M</code>
152     command line option.</p>
153   </section>
154
155   <section id="scope">
156     <title>Scope of Directives</title>
157
158     <related>
159       <directivelist>
160         <directive module="core" type="section">Directory</directive>
161         <directive module="core" type="section">DirectoryMatch</directive>
162         <directive module="core" type="section">Files</directive>
163         <directive module="core" type="section">FilesMatch</directive>
164         <directive module="core" type="section">Location</directive>
165         <directive module="core" type="section">LocationMatch</directive>
166         <directive module="core" type="section">VirtualHost</directive>
167       </directivelist>
168     </related>
169
170     <p>Directives placed in the main configuration files apply to
171     the entire server. If you wish to change the configuration for
172     only a part of the server, you can scope your directives by
173     placing them in <directive module="core"
174     type="section">Directory</directive>, <directive module="core"
175     type="section">DirectoryMatch</directive>, <directive module="core"
176     type="section">Files</directive>, <directive module="core"
177     type="section">FilesMatch</directive>, <directive module="core"
178     type="section">Location</directive>, and <directive module="core"
179     type="section">LocationMatch</directive>
180     sections. These sections limit the application of the
181     directives which they enclose to particular filesystem
182     locations or URLs. They can also be nested, allowing for very
183     fine grained configuration.</p>
184
185     <p>httpd has the capability to serve many different websites
186     simultaneously. This is called <a href="vhosts/">Virtual
187     Hosting</a>. Directives can also be scoped by placing them
188     inside <directive module="core" type="section">VirtualHost</directive>
189     sections, so that they will only apply to requests for a
190     particular website.</p>
191
192     <p>Although most directives can be placed in any of these
193     sections, some directives do not make sense in some contexts.
194     For example, directives controlling process creation can only
195     be placed in the main server context. To find which directives
196     can be placed in which sections, check the <a
197     href="mod/directive-dict.html#Context">Context</a> of the
198     directive. For further information, we provide details on <a
199     href="sections.html">How Directory, Location and Files sections
200     work</a>.</p>
201   </section>
202
203   <section id="htaccess">
204     <title>.htaccess Files</title>
205
206     <related>
207       <directivelist>
208         <directive module="core">AccessFileName</directive>
209         <directive module="core">AllowOverride</directive>
210       </directivelist>
211     </related>
212
213     <p>httpd allows for decentralized management of configuration
214     via special files placed inside the web tree. The special files
215     are usually called <code>.htaccess</code>, but any name can be
216     specified in the <directive module="core">AccessFileName</directive>
217     directive. Directives placed in <code>.htaccess</code> files
218     apply to the directory where you place the file, and all
219     sub-directories. The <code>.htaccess</code> files follow the
220     same syntax as the main configuration files. Since
221     <code>.htaccess</code> files are read on every request, changes
222     made in these files take immediate effect.</p>
223
224     <p>To find which directives can be placed in
225     <code>.htaccess</code> files, check the <a
226     href="mod/directive-dict.html#Context">Context</a> of the
227     directive. The server administrator further controls what
228     directives may be placed in <code>.htaccess</code> files by
229     configuring the <directive module="core">AllowOverride</directive>
230     directive in the main configuration files.</p>
231
232     <p>For more information on <code>.htaccess</code> files, see
233     the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>
234   </section>
235 </manualpage>