Configuration Files
This document describes the files used to configure Apache HTTP Server.
| Related Modules | Related Directives | |---|---|
command line flag. In addition, other configuration files may be added using the
directive, and wildcards can be used to include many configuration files. Any directive may be placed in any of these configuration files. Changes to the main configuration files are only recognized by httpd when it is started or restarted.Include
The server also reads a file containing mime document types; the filename is set by the
Arguments to directives are separated by whitespace. If an argument contains spaces, you must enclose that argument in quotes.
Directives in the configuration files are case-insensitive, but arguments to directives are often case sensitive. Lines that begin with the hash character "#" are considered comments, and are ignored. Comments may not be included on a line after a configuration directive. Blank lines and white space occurring before a directive are ignored, so you may indent directives for clarity.
The values of variables defined with the
of or shell environment variables can be used in configuration file lines using the syntax Define${VAR}
. If "VAR" is the name of a valid variable, the value of that variable is substituted into that spot in the configuration file line, and processing continues as if that text were found directly in the configuration file. Variables defined with
take precedence over shell environment variables. If the "VAR" variable is not found, the characters Define${VAR}
are left unchanged, and a warning is logged. Variable names may not contain colon ":" characters, to avoid clashes with
Only shell environment variables defined before the server is started can be used in expansions. Environment variables defined in the configuration file itself, for example with
, take effect too late to be used for expansions in the configuration file.SetEnv
The maximum length of a line in normal configuration files, after variable substitution and joining any continued lines, is approximately 16 MiB. In .htaccess files, the maximum length is 8190 characters.
You can check your configuration files for syntax errors without starting the server by using apache2ctl configtest
to dump the configuration with all included files and environment variables resolved and all comments and non-matching
sections
removed. However, the output does not reflect the merging or overriding
that may happen for repeated directives.
httpd is a modular server. This implies that only the most basic functionality is included in the core server. Extended features are available through modules which can be loaded into httpd. By default, a base set of modules is included in the server at compile-time. If the server is compiled to use dynamically loaded modules, then modules can be compiled separately and added at any time using the
directive. Otherwise, httpd must be recompiled to add or remove modules. Configuration directives may be included conditional on a presence of a particular module by enclosing them in an LoadModule
blocks are not required, and in some cases may mask the fact that you're missing an important module.
sections. These sections limit the application of the
directives which they enclose to particular filesystem
locations or URLs. They can also be nested, allowing for very
fine grained configuration.
httpd has the capability to serve many different websites simultaneously. This is called Virtual Hosting. Directives can also be scoped by placing them inside
sections, so that they will only apply to requests for a
particular website.
Although most directives can be placed in any of these sections, some directives do not make sense in some contexts. For example, directives controlling process creation can only be placed in the main server context. To find which directives can be placed in which sections, check the Context of the directive. For further information, we provide details on How Directory, Location and Files sections work.
files follow the same syntax as the main configuration files. Since .htaccess
files are read on every request, changes made in these files take immediate effect.
files, check the Context of the directive. The server administrator further controls what directives may be placed in .htaccess
files, see the .htaccess tutorial.
Modules | Directives | FAQ | Glossary | Sitemap
Apache HTTP Server Version 2.4
Configuration Files
Available Languages: de | en | fr | ja | ko | tr
Main Configuration Files
Apache HTTP Server is configured by placing directives in plain text configuration files. The main configuration file is usually called apache2.conf. The location of this file is set at compile-time, but may be overridden with the -f command line flag. In addition, other configuration files may be a
Syntax of the Configuration Files
httpd configuration files contain one directive per line. The backslash "\" may be used as the last character on a line to indicate that the directive continues onto the next line. There must be no other characters or white space between the backslash and the end of the line.
Modules
httpd is a modular server. This implies that only the most basic functionality is included in the core server. Extended features are available through modules which can be loaded into httpd. By default, a base set of modules is included in the server at compile-time. If the server is compiled to use
Scope of Directives
Directives placed in the main configuration files apply to the entire server. If you wish to change the configuration for only a part of the server, you can scope your directives by placing them in
.htaccess Files
httpd allows for decentralized management of configuration via special files placed inside the web tree. The special files are usually called .htaccess, but any name can be specified in the AccessFileName directive. Directives placed in .htaccess files apply to the directory where you place the file