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"?>
6 Copyright 2002-2004 The Apache Software Foundation
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
12 http://www.apache.org/licenses/LICENSE-2.0
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.
21 <manualpage metafile="configuring.xml.meta">
23 <title>Configuration Files</title>
26 <p>This document describes the files used to configure the Apache
31 <title>Main Configuration Files</title>
34 <module>mod_mime</module>
37 <directive module="core" type="section">IfDefine</directive>
38 <directive module="core">Include</directive>
39 <directive module="mod_mime">TypesConfig</directive>
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>
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>
62 <title>Syntax of the Configuration Files</title>
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>
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>
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
84 <section id="modules">
85 <title>Modules</title>
89 <module>mod_so</module>
92 <directive module="core" type="section">IfModule</directive>
93 <directive module="mod_so">LoadModule</directive>
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>
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>
113 <p>To see which modules are currently compiled into the server,
114 you can use the <code>-l</code> command line option.</p>
118 <title>Scope of Directives</title>
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>
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>
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>
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
165 <section id="htaccess">
166 <title>.htaccess Files</title>
170 <directive module="core">AccessFileName</directive>
171 <directive module="core">AllowOverride</directive>
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>
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>
194 <p>For more information on <code>.htaccess</code> files, see
195 the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>