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$ -->
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
14 http://www.apache.org/licenses/LICENSE-2.0
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.
23 <manualpage metafile="configuring.xml.meta">
25 <title>Configuration Files</title>
28 <p>This document describes the files used to configure the Apache
33 <title>Main Configuration Files</title>
36 <module>mod_mime</module>
39 <directive module="core" type="section">IfDefine</directive>
40 <directive module="core">Include</directive>
41 <directive module="mod_mime">TypesConfig</directive>
45 <p>Apache 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 Apache when it is started or restarted.</p>
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>
64 <title>Syntax of the Configuration Files</title>
66 <p>Apache configuration files contain one directive per line.
67 The back-slash "\" 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 back-slash and the end of the line.</p>
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>
80 <p>The maximum length of a line in the configuration file,
81 after joining any continued lines and removing leading and
82 trailing white space, is 8192 characters.</p>
84 <p>You can check your configuration files for syntax errors
85 without starting the server by using <code>apachectl
86 configtest</code> or the <code>-t</code> command line
90 <section id="modules">
91 <title>Modules</title>
95 <module>mod_so</module>
98 <directive module="core" type="section">IfModule</directive>
99 <directive module="mod_so">LoadModule</directive>
103 <p>Apache is a modular server. This implies that only the most
104 basic functionality is included in the core server. Extended
105 features are available through <a
106 href="mod/">modules</a> which can be loaded
107 into Apache. By default, a <a
108 href="mod/module-dict.html#Status">base</a> set of modules is
109 included in the server at compile-time. If the server is
110 compiled to use <a href="dso.html">dynamically loaded</a>
111 modules, then modules can be compiled separately and added at
112 any time using the <directive module="mod_so">LoadModule</directive>
114 Otherwise, Apache must be recompiled to add or remove modules.
115 Configuration directives may be included conditional on a
116 presence of a particular module by enclosing them in an <directive
117 module="core" type="section">IfModule</directive> block.</p>
119 <p>To see which modules are currently compiled into the server,
120 you can use the <code>-l</code> command line option.</p>
124 <title>Scope of Directives</title>
128 <directive module="core" type="section">Directory</directive>
129 <directive module="core" type="section">DirectoryMatch</directive>
130 <directive module="core" type="section">Files</directive>
131 <directive module="core" type="section">FilesMatch</directive>
132 <directive module="core" type="section">Location</directive>
133 <directive module="core" type="section">LocationMatch</directive>
134 <directive module="core" type="section">VirtualHost</directive>
138 <p>Directives placed in the main configuration files apply to
139 the entire server. If you wish to change the configuration for
140 only a part of the server, you can scope your directives by
141 placing them in <directive module="core"
142 type="section">Directory</directive>, <directive module="core"
143 type="section">DirectoryMatch</directive>, <directive module="core"
144 type="section">Files</directive>, <directive module="core"
145 type="section">FilesMatch</directive>, <directive module="core"
146 type="section">Location</directive>, and <directive module="core"
147 type="section">LocationMatch</directive>
148 sections. These sections limit the application of the
149 directives which they enclose to particular filesystem
150 locations or URLs. They can also be nested, allowing for very
151 fine grained configuration.</p>
153 <p>Apache has the capability to serve many different websites
154 simultaneously. This is called <a href="vhosts/">Virtual
155 Hosting</a>. Directives can also be scoped by placing them
156 inside <directive module="core" type="section">VirtualHost</directive>
157 sections, so that they will only apply to requests for a
158 particular website.</p>
160 <p>Although most directives can be placed in any of these
161 sections, some directives do not make sense in some contexts.
162 For example, directives controlling process creation can only
163 be placed in the main server context. To find which directives
164 can be placed in which sections, check the <a
165 href="mod/directive-dict.html#Context">Context</a> of the
166 directive. For further information, we provide details on <a
167 href="sections.html">How Directory, Location and Files sections
171 <section id="htaccess">
172 <title>.htaccess Files</title>
176 <directive module="core">AccessFileName</directive>
177 <directive module="core">AllowOverride</directive>
181 <p>Apache allows for decentralized management of configuration
182 via special files placed inside the web tree. The special files
183 are usually called <code>.htaccess</code>, but any name can be
184 specified in the <directive module="core">AccessFileName</directive>
185 directive. Directives placed in <code>.htaccess</code> files
186 apply to the directory where you place the file, and all
187 sub-directories. The <code>.htaccess</code> files follow the
188 same syntax as the main configuration files. Since
189 <code>.htaccess</code> files are read on every request, changes
190 made in these files take immediate effect.</p>
192 <p>To find which directives can be placed in
193 <code>.htaccess</code> files, check the <a
194 href="mod/directive-dict.html#Context">Context</a> of the
195 directive. The server administrator further controls what
196 directives may be placed in <code>.htaccess</code> files by
197 configuring the <directive module="core">AllowOverride</directive>
198 directive in the main configuration files.</p>
200 <p>For more information on <code>.htaccess</code> files, see
201 the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>