]> granicus.if.org Git - apache/blob - docs/manual/configuring.xml
fix name of The Apache Software Foundation
[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
5 <!--
6  Copyright 2002-2004 The Apache Software Foundation
7
8  Licensed under the Apache License, Version 2.0 (the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11
12      http://www.apache.org/licenses/LICENSE-2.0
13
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 -->
20
21 <manualpage metafile="configuring.xml.meta">
22
23   <title>Configuration Files</title>
24
25 <summary>
26 <p>This document describes the files used to configure the Apache
27 HTTP server.</p>
28 </summary>
29
30   <section id="main">
31     <title>Main Configuration Files</title>
32     <related>
33       <modulelist>
34         <module>mod_mime</module>
35       </modulelist>
36       <directivelist>
37         <directive module="core" type="section">IfDefine</directive>
38         <directive module="core">Include</directive>
39         <directive module="mod_mime">TypesConfig</directive>
40       </directivelist>
41     </related>
42
43     <p>Apache is configured by placing <a
44     href="mod/directives.html">directives</a> in plain text
45     configuration files. The main configuration file is usually called
46     <code>httpd.conf</code>. The location of this file is set at
47     compile-time, but may be overridden with the <code>-f</code>
48     command line flag. In addition, other configuration files may be
49     added using the <directive module="core">Include</directive>
50     directive, and wildcards can be used to include many configuration
51     files. Any directive may be placed in any of these configuration
52     files.  Changes to the main configuration files are only
53     recognized by Apache when it is started or restarted.</p>
54
55     <p>The server also reads a file containing mime document types;
56     the filename is set by the <directive
57     module="mod_mime">TypesConfig</directive> directive,
58     and is <code>mime.types</code> by default.</p>
59   </section>
60
61   <section id="syntax">
62     <title>Syntax of the Configuration Files</title>
63
64     <p>Apache configuration files contain one directive per line.
65     The back-slash "\" may be used as the last character on a line
66     to indicate that the directive continues onto the next line.
67     There must be no other characters or white space between the
68     back-slash and the end of the line.</p>
69
70     <p>Directives in the configuration files are case-insensitive,
71     but arguments to directives are often case sensitive. Lines
72     that begin with the hash character "#" are considered
73     comments, and are ignored. Comments may <strong>not</strong> be
74     included on a line after a configuration directive. Blank lines
75     and white space occurring before a directive are ignored, so
76     you may indent directives for clarity.</p>
77
78     <p>You can check your configuration files for syntax errors
79     without starting the server by using <code>apachectl
80     configtest</code> or the <code>-t</code> command line
81     option.</p>
82   </section>
83
84   <section id="modules">
85     <title>Modules</title>
86
87     <related>
88       <modulelist>
89         <module>mod_so</module>
90       </modulelist>
91       <directivelist>
92         <directive module="core" type="section">IfModule</directive>
93         <directive module="mod_so">LoadModule</directive>
94       </directivelist>
95     </related>
96
97     <p>Apache is a modular server. This implies that only the most
98     basic functionality is included in the core server. Extended
99     features are available through <a
100     href="mod/">modules</a> which can be loaded
101     into Apache. By default, a <a
102     href="mod/module-dict.html#Status">base</a> set of modules is
103     included in the server at compile-time. If the server is
104     compiled to use <a href="dso.html">dynamically loaded</a>
105     modules, then modules can be compiled separately and added at
106     any time using the <directive module="mod_so">LoadModule</directive>
107     directive.
108     Otherwise, Apache must be recompiled to add or remove modules.
109     Configuration directives may be included conditional on a
110     presence of a particular module by enclosing them in an<directive
111     module="core" type="section">IfModule</directive> block.</p>
112
113     <p>To see which modules are currently compiled into the server,
114     you can use the <code>-l</code> command line option.</p>
115   </section>
116
117   <section id="scope">
118     <title>Scope of Directives</title>
119
120     <related>
121       <directivelist>
122         <directive module="core" type="section">Directory</directive>
123         <directive module="core" type="section">DirectoryMatch</directive>
124         <directive module="core" type="section">Files</directive>
125         <directive module="core" type="section">FilesMatch</directive>
126         <directive module="core" type="section">Location</directive>
127         <directive module="core" type="section">LocationMatch</directive>
128         <directive module="core" type="section">VirtualHost</directive>
129       </directivelist>
130     </related>
131
132     <p>Directives placed in the main configuration files apply to
133     the entire server. If you wish to change the configuration for
134     only a part of the server, you can scope your directives by
135     placing them in <directive module="core"
136     type="section">Directory</directive>, <directive module="core"
137     type="section">DirectoryMatch</directive>, <directive module="core"
138     type="section">Files</directive>, <directive module="core"
139     type="section">FilesMatch</directive>, <directive module="core"
140     type="section">Location</directive>, and <directive module="core"
141     type="section">LocationMatch</directive>
142     sections. These sections limit the application of the
143     directives which they enclose to particular filesystem
144     locations or URLs. They can also be nested, allowing for very
145     fine grained configuration.</p>
146
147     <p>Apache has the capability to serve many different websites
148     simultaneously. This is called <a href="vhosts/">Virtual
149     Hosting</a>. Directives can also be scoped by placing them
150     inside <directive module="core" type="section">VirtualHost</directive>
151     sections, so that they will only apply to requests for a
152     particular website.</p>
153
154     <p>Although most directives can be placed in any of these
155     sections, some directives do not make sense in some contexts.
156     For example, directives controlling process creation can only
157     be placed in the main server context. To find which directives
158     can be placed in which sections, check the <a
159     href="mod/directive-dict.html#Context">Context</a> of the
160     directive. For further information, we provide details on <a
161     href="sections.html">How Directory, Location and Files sections
162     work</a>.</p>
163   </section>
164
165   <section id="htaccess">
166     <title>.htaccess Files</title>
167
168     <related>
169       <directivelist>
170         <directive module="core">AccessFileName</directive>
171         <directive module="core">AllowOverride</directive>
172       </directivelist>
173     </related>
174
175     <p>Apache allows for decentralized management of configuration
176     via special files placed inside the web tree. The special files
177     are usually called <code>.htaccess</code>, but any name can be
178     specified in the <directive module="core">AccessFileName</directive>
179     directive. Directives placed in <code>.htaccess</code> files
180     apply to the directory where you place the file, and all
181     sub-directories. The <code>.htaccess</code> files follow the
182     same syntax as the main configuration files. Since
183     <code>.htaccess</code> files are read on every request, changes
184     made in these files take immediate effect.</p>
185
186     <p>To find which directives can be placed in
187     <code>.htaccess</code> files, check the <a
188     href="mod/directive-dict.html#Context">Context</a> of the
189     directive. The server administrator further controls what
190     directives may be placed in <code>.htaccess</code> files by
191     configuring the <directive module="core">AllowOverride</directive>
192     directive in the main configuration files.</p>
193
194     <p>For more information on <code>.htaccess</code> files, see
195     the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>
196   </section>
197 </manualpage>