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>You can check your configuration files for syntax errors
81 without starting the server by using <code>apachectl
82 configtest</code> or the <code>-t</code> command line
86 <section id="modules">
87 <title>Modules</title>
91 <module>mod_so</module>
94 <directive module="core" type="section">IfModule</directive>
95 <directive module="mod_so">LoadModule</directive>
99 <p>Apache is a modular server. This implies that only the most
100 basic functionality is included in the core server. Extended
101 features are available through <a
102 href="mod/">modules</a> which can be loaded
103 into Apache. By default, a <a
104 href="mod/module-dict.html#Status">base</a> set of modules is
105 included in the server at compile-time. If the server is
106 compiled to use <a href="dso.html">dynamically loaded</a>
107 modules, then modules can be compiled separately and added at
108 any time using the <directive module="mod_so">LoadModule</directive>
110 Otherwise, Apache must be recompiled to add or remove modules.
111 Configuration directives may be included conditional on a
112 presence of a particular module by enclosing them in an <directive
113 module="core" type="section">IfModule</directive> block.</p>
115 <p>To see which modules are currently compiled into the server,
116 you can use the <code>-l</code> command line option.</p>
120 <title>Scope of Directives</title>
124 <directive module="core" type="section">Directory</directive>
125 <directive module="core" type="section">DirectoryMatch</directive>
126 <directive module="core" type="section">Files</directive>
127 <directive module="core" type="section">FilesMatch</directive>
128 <directive module="core" type="section">Location</directive>
129 <directive module="core" type="section">LocationMatch</directive>
130 <directive module="core" type="section">VirtualHost</directive>
134 <p>Directives placed in the main configuration files apply to
135 the entire server. If you wish to change the configuration for
136 only a part of the server, you can scope your directives by
137 placing them in <directive module="core"
138 type="section">Directory</directive>, <directive module="core"
139 type="section">DirectoryMatch</directive>, <directive module="core"
140 type="section">Files</directive>, <directive module="core"
141 type="section">FilesMatch</directive>, <directive module="core"
142 type="section">Location</directive>, and <directive module="core"
143 type="section">LocationMatch</directive>
144 sections. These sections limit the application of the
145 directives which they enclose to particular filesystem
146 locations or URLs. They can also be nested, allowing for very
147 fine grained configuration.</p>
149 <p>Apache has the capability to serve many different websites
150 simultaneously. This is called <a href="vhosts/">Virtual
151 Hosting</a>. Directives can also be scoped by placing them
152 inside <directive module="core" type="section">VirtualHost</directive>
153 sections, so that they will only apply to requests for a
154 particular website.</p>
156 <p>Although most directives can be placed in any of these
157 sections, some directives do not make sense in some contexts.
158 For example, directives controlling process creation can only
159 be placed in the main server context. To find which directives
160 can be placed in which sections, check the <a
161 href="mod/directive-dict.html#Context">Context</a> of the
162 directive. For further information, we provide details on <a
163 href="sections.html">How Directory, Location and Files sections
167 <section id="htaccess">
168 <title>.htaccess Files</title>
172 <directive module="core">AccessFileName</directive>
173 <directive module="core">AllowOverride</directive>
177 <p>Apache allows for decentralized management of configuration
178 via special files placed inside the web tree. The special files
179 are usually called <code>.htaccess</code>, but any name can be
180 specified in the <directive module="core">AccessFileName</directive>
181 directive. Directives placed in <code>.htaccess</code> files
182 apply to the directory where you place the file, and all
183 sub-directories. The <code>.htaccess</code> files follow the
184 same syntax as the main configuration files. Since
185 <code>.htaccess</code> files are read on every request, changes
186 made in these files take immediate effect.</p>
188 <p>To find which directives can be placed in
189 <code>.htaccess</code> files, check the <a
190 href="mod/directive-dict.html#Context">Context</a> of the
191 directive. The server administrator further controls what
192 directives may be placed in <code>.htaccess</code> files by
193 configuring the <directive module="core">AllowOverride</directive>
194 directive in the main configuration files.</p>
196 <p>For more information on <code>.htaccess</code> files, see
197 the <a href="howto/htaccess.html">.htaccess tutorial</a>.</p>