1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4 <TITLE>Configuration Files</TITLE>
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
15 <!--#include virtual="header.html" -->
16 <H1 ALIGN="CENTER">Configuration Files</H1>
19 <li><a href="#main">Main Configuration Files</a></li>
20 <li><a href="#syntax">Syntax of the Configuration Files</a></li>
21 <li><a href="#modules">Modules</a></li>
22 <li><a href="#scope">Scope of Directives</a></li>
23 <li><a href="#htaccess">.htaccess Files</a></li>
28 <H2><a name="main">Main Configuration Files</a></H2>
30 <table border="1"><tr><td valign="top">
31 <strong>Related Modules</strong><br><br>
32 <a href="mod/mod_mime.html">mod_mime</a><br>
36 <strong>Related Directives</strong><br><br>
37 <A HREF="mod/core.html#ifdefine"><IfDefine></A><br>
38 <a href="mod/core.html#include">Include</a><br>
39 <A HREF="mod/mod_mime.html#typesconfig">TypesConfig</A><br>
42 <P>Apache is configured by placing <A HREF="mod/directives.html"
43 >directives</A> in plain text configuration files. The main
44 configuration file is usually called <CODE>httpd.conf</CODE>. The
45 location of this file is set at compile-time, but may be overridden
46 with the <CODE>-f</CODE> command line flag. In addition, other
47 configuration files may be added using the <CODE><A
48 HREF="mod/core.html#include">Include</A></CODE> directive. Any
49 directive may be placed in any of these configuration files. Changes
50 to the main configuration files are only recognized by Apache when it
51 is started or restarted.</p>
53 <P>New with Apache 1.3.13 is a feature where if any configuration
54 file is actually a directory, Apache will enter that directory
55 and parse any files (and subdirectories) found there as configuration
56 files. One possible use for this would be to add VirtualHosts
57 by creating small configuration files for each host, and placing
58 them in such a configuration directory. Thus, you can add or
59 remove VirtualHosts without editing any files at all, simply
60 adding or deleting them. This makes automating such processes
64 The server also reads a file containing mime document types; the
65 filename is set by the <A HREF="mod/mod_mime.html#typesconfig"
66 >TypesConfig</A> directive, and is <CODE>mime.types</CODE> by default.
70 <H2><a name="syntax">Syntax of the Configuration Files</a></H2>
72 <P>Apache configuration files contain one directive per line. The
73 back-slash "\" may be used as the last character on a line to indicate
74 that the directive continues onto the next line. There must be no
75 other characters or white space between the back-slash and the end of
78 <P>Directives in the configuration files are case-insensitive, but
79 arguments to directives are often case sensitive. Lines which begin
80 with the hash character "#" are considered comments, and are ignored.
81 Comments may <STRONG>not</STRONG> be included on a line after a
82 configuration directive. Blank lines and white space occurring before
83 a directive are ignored, so you may indent directives for clarity.
85 <P>You can check your configuration files for syntax errors without
86 starting the server by using <CODE>apachectl configtest</CODE>
87 or the <CODE>-t</CODE> command line option.
91 <H2><a name="modules">Modules</a></H2>
93 <table border="1"><tr><td valign="top">
94 <strong>Related Modules</strong><br><br>
95 <a href="mod/mod_so.html">mod_so</a><br>
98 <strong>Related Directives</strong><br><br>
99 <A HREF="mod/core.html#addmodule">AddModule</A><br>
100 <A HREF="mod/core.html#clearmodulelist">ClearModuleList</A><br>
101 <A HREF="mod/core.html#ifmodule"><IfModule></A><br>
102 <a href="mod/mod_so.html#loadmodule">LoadModule</a><br>
105 <P>Apache is a modular server. This implies that only the most basic
106 functionality is included in the core server. Extended features are
107 available through <A HREF="mod/index-bytype.html">modules</A> which
108 can be loaded into Apache. By default, a <A
109 HREF="mod/module-dict.html#Status">base</A> set of modules is
110 included in the server at compile-time. If the server is compiled to
111 use <A HREF="dso.html">dynamically loaded</A> modules, then modules
112 can be compiled separately and added at any time using the <A
113 HREF="mod/mod_so.html#loadmodule">LoadModule</A> directive.
114 Otherwise, Apache must be recompiled to add or remove modules.
115 Configuration directives may be included conditional on a presence of
116 a particular module by enclosing them in an <A
117 HREF="mod/core.html#ifmodule"><IfModule></A> block.
119 <P>To see which modules are currently compiled into the server,
120 you can use the <CODE>-l</CODE> command line option.
124 <H2><a name="scope">Scope of Directives</a></H2>
126 <table border="1"><tr><td valign="top">
127 <strong>Related Directives</strong><br><br>
128 <A HREF="mod/core.html#directory"><Directory></A><br>
129 <A HREF="mod/core.html#directorymatch"><DirectoryMatch></A><br>
130 <A HREF="mod/core.html#files"><Files></A><br>
131 <A HREF="mod/core.html#filesmatch"><FilesMatch></A><br>
132 <A HREF="mod/core.html#location"><Location></A><br>
133 <A HREF="mod/core.html#locationmatch"><LocationMatch></A><br>
134 <a href="mod/core.html#virtualhost"><VirtualHost></a><br>
137 <P>Directives placed in the main configuration files apply to the entire
138 server. If you wish to change the configuration for only a part of
139 the server, you can scope your directives by placing them in
140 <CODE><A HREF="mod/core.html#directory"><Directory></A>,
141 <A HREF="mod/core.html#directorymatch"><DirectoryMatch></A>,
142 <A HREF="mod/core.html#files"><Files></A>,
143 <A HREF="mod/core.html#filesmatch"><FilesMatch></A>,
144 <A HREF="mod/core.html#location"><Location></A>,
146 <A HREF="mod/core.html#locationmatch"><LocationMatch></A>
148 sections. These sections limit the application of the directives
149 which they enclose to particular filesystem locations or URLs. They
150 can also be nested, allowing for very fine grained configuration.
152 <P>Apache has the capability to serve many different websites
153 simultaneously. This is called <A HREF="vhosts/">Virtual Hosting</A>.
154 Directives can also be scoped by placing them inside
155 <CODE><A HREF="mod/core.html#virtualhost"><VirtualHost></A></CODE>
156 sections, so that they will only apply to requests for a particular
159 <P>Although most directives can be placed in any of these sections,
160 some directives do not make sense in some contexts. For example,
161 directives controlling process creation can only be placed in the main
162 server context. To find which directives can be placed in which
163 sections, check the <A
164 HREF="mod/directive-dict.html#Context">Context</A> of the directive.
165 For further information, we provide details on <A
166 HREF="sections.html">How Directory, Location and Files sections
171 <H2><a name="htaccess">.htaccess Files</a></H2>
173 <table border="1"><tr><td valign="top">
174 <strong>Related Directives</strong><br><br>
175 <A HREF="mod/core.html#accessfilename">AccessFileName</A><br>
176 <A HREF="mod/core.html#allowoverride">AllowOverride</A><br>
179 <P>Apache allows for decentralized management of configuration via
180 special files placed inside the web tree. The special files are
181 usually called <CODE>.htaccess</CODE>, but any name can be specified
182 in the <A HREF="mod/core.html#accessfilename"><CODE
183 >AccessFileName</CODE></A> directive. Directives placed in
184 <CODE>.htaccess</CODE> files apply to the directory where you place
185 the file, and all sub-directories. The <CODE>.htaccess</CODE> files
186 follow the same syntax as the main configuration files. Since
187 <CODE>.htaccess</CODE> files are read on every request, changes made
188 in these files take immediate effect.
190 <P>To find which directives can be placed in <CODE>.htaccess</CODE>
191 files, check the <A HREF="mod/directive-dict.html#Context">Context</A>
192 of the directive. The server administrator further controls what
193 directives may be placed in <CODE>.htaccess</CODE> files by
195 HREF="mod/core.html#allowoverride"><CODE>AllowOverride</CODE></A>
196 directive in the main configuration files.
198 <!--#include virtual="footer.html" -->