]> granicus.if.org Git - apache/blob - docs/manual/configuring.xml
In as much as we can be said to have consensus on anything at all, we
[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 HTTPD.</p>
29 </summary>
30
31   <section id="main">
32     <title>Main Configuration Files</title>
33     <related>
34       <modulelist>
35         <module>mod_mime</module>
36       </modulelist>
37       <directivelist>
38         <directive module="core" type="section">IfDefine</directive>
39         <directive module="core">Include</directive>
40         <directive module="mod_mime">TypesConfig</directive>
41       </directivelist>
42     </related>
43
44     <p>Apache HTTPD is configured by placing <a
45     href="mod/directives.html">directives</a> in plain text
46     configuration files. The main configuration file is usually called
47     <code>httpd.conf</code>. The location of this file is set at
48     compile-time, but may be overridden with the <code>-f</code>
49     command line flag. In addition, other configuration files may be
50     added using the <directive module="core">Include</directive>
51     directive, and wildcards can be used to include many configuration
52     files. Any directive may be placed in any of these configuration
53     files.  Changes to the main configuration files are only
54     recognized by httpd when it is started or restarted.</p>
55
56     <p>The server also reads a file containing mime document types;
57     the filename is set by the <directive
58     module="mod_mime">TypesConfig</directive> directive,
59     and is <code>mime.types</code> by default.</p>
60   </section>
61
62   <section id="syntax">
63     <title>Syntax of the Configuration Files</title>
64
65     <p>httpd configuration files contain one directive per line.
66     The back-slash "\" may be used as the last character on a line
67     to indicate that the directive continues onto the next line.
68     There must be no other characters or white space between the
69     back-slash and the end of the line.</p>
70
71     <p>Directives in the configuration files are case-insensitive,
72     but arguments to directives are often case sensitive. Lines
73     that begin with the hash character "#" are considered
74     comments, and are ignored. Comments may <strong>not</strong> be
75     included on a line after a configuration directive. Blank lines
76     and white space occurring before a directive are ignored, so
77     you may indent directives for clarity.</p>
78
79     <p>The values of shell environment variables can be used in
80     configuration file lines using the syntax <code>${ENVVAR}</code>.
81     If "ENVVAR" is the name of a valid environment variable, the value
82     of that variable is substituted into that spot in the
83     configuration file line, and processing continues as if that text
84     were found directly in the configuration file.  (If the ENVVAR
85     variable is not found, the characters "${ENVVAR}" are left
86     unchanged for use by later stages in the config file
87     processing.)</p>
88
89     <p>Only environment variables defined before the server is started
90     can be used in expansions.  Variables defined in the
91     configuration file itself, for example with <directive
92     module="mod_env">SetEnv</directive>, take effect too late to be
93     used for expansions in the configuration file.</p>
94
95     <p>The maximum length of a line in the configuration file, after
96     environment-variable substitution, joining any continued lines and
97     removing leading and trailing white space, is 8192 characters.</p>
98
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
102     option.</p>
103   </section>
104
105   <section id="modules">
106     <title>Modules</title>
107
108     <related>
109       <modulelist>
110         <module>mod_so</module>
111       </modulelist>
112       <directivelist>
113         <directive module="core" type="section">IfModule</directive>
114         <directive module="mod_so">LoadModule</directive>
115       </directivelist>
116     </related>
117
118     <p>httpd is a modular server. This implies that only the most
119     basic functionality is included in the core server. Extended
120     features are available through <a
121     href="mod/">modules</a> which can be loaded
122     into httpd. By default, a <a
123     href="mod/module-dict.html#Status">base</a> set of modules is
124     included in the server at compile-time. If the server is
125     compiled to use <a href="dso.html">dynamically loaded</a>
126     modules, then modules can be compiled separately and added at
127     any time using the <directive module="mod_so">LoadModule</directive>
128     directive.
129     Otherwise, httpd must be recompiled to add or remove modules.
130     Configuration directives may be included conditional on a
131     presence of a particular module by enclosing them in an <directive
132     module="core" type="section">IfModule</directive> block.</p>
133
134     <p>To see which modules are currently compiled into the server,
135     you can use the <code>-l</code> command line option.</p>
136   </section>
137
138   <section id="scope">
139     <title>Scope of Directives</title>
140
141     <related>
142       <directivelist>
143         <directive module="core" type="section">Directory</directive>
144         <directive module="core" type="section">DirectoryMatch</directive>
145         <directive module="core" type="section">Files</directive>
146         <directive module="core" type="section">FilesMatch</directive>
147         <directive module="core" type="section">Location</directive>
148         <directive module="core" type="section">LocationMatch</directive>
149         <directive module="core" type="section">VirtualHost</directive>
150       </directivelist>
151     </related>
152
153     <p>Directives placed in the main configuration files apply to
154     the entire server. If you wish to change the configuration for
155     only a part of the server, you can scope your directives by
156     placing them in <directive module="core"
157     type="section">Directory</directive>, <directive module="core"
158     type="section">DirectoryMatch</directive>, <directive module="core"
159     type="section">Files</directive>, <directive module="core"
160     type="section">FilesMatch</directive>, <directive module="core"
161     type="section">Location</directive>, and <directive module="core"
162     type="section">LocationMatch</directive>
163     sections. These sections limit the application of the
164     directives which they enclose to particular filesystem
165     locations or URLs. They can also be nested, allowing for very
166     fine grained configuration.</p>
167
168     <p>httpd has the capability to serve many different websites
169     simultaneously. This is called <a href="vhosts/">Virtual
170     Hosting</a>. Directives can also be scoped by placing them
171     inside <directive module="core" type="section">VirtualHost</directive>
172     sections, so that they will only apply to requests for a
173     particular website.</p>
174
175     <p>Although most directives can be placed in any of these
176     sections, some directives do not make sense in some contexts.
177     For example, directives controlling process creation can only
178     be placed in the main server context. To find which directives
179     can be placed in which sections, check the <a
180     href="mod/directive-dict.html#Context">Context</a> of the
181     directive. For further information, we provide details on <a
182     href="sections.html">How Directory, Location and Files sections
183     work</a>.</p>
184   </section>
185
186   <section id="htaccess">
187     <title>.htaccess Files</title>
188
189     <related>
190       <directivelist>
191         <directive module="core">AccessFileName</directive>
192         <directive module="core">AllowOverride</directive>
193       </directivelist>
194     </related>
195
196     <p>httpd allows for decentralized management of configuration
197     via special files placed inside the web tree. The special files
198     are usually called <code>.htaccess</code>, but any name can be
199     specified in the <directive module="core">AccessFileName</directive>
200     directive. Directives placed in <code>.htaccess</code> files
201     apply to the directory where you place the file, and all
202     sub-directories. The <code>.htaccess</code> files follow the
203     same syntax as the main configuration files. Since
204     <code>.htaccess</code> files are read on every request, changes
205     made in these files take immediate effect.</p>
206
207     <p>To find which directives can be placed in
208     <code>.htaccess</code> files, check the <a
209     href="mod/directive-dict.html#Context">Context</a> of the
210     directive. The server administrator further controls what
211     directives may be placed in <code>.htaccess</code> files by
212     configuring the <directive module="core">AllowOverride</directive>
213     directive in the main configuration files.</p>
214
215     <p>For more information on <code>.htaccess</code> files, see
216     the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>
217   </section>
218 </manualpage>