The first things Apache needs from the configuration file are basics
like the listening port, server name, the default locations for
content, logs, and other important files, and what modules to load.
After that, the wider server functionality is configured. This
includes access control, virtual hosts, special resource handling,
and module-specific directives.
Here are some basic directives you might find in the
httpd.conf configuration file:
ServerType standalone
Port 80
ServerAdmin webmaster@oreilly.com
ServerName webnuts.oreilly.com
User nobody
Group nobody
Each directive here specifies a property of the
server's configuration and binds it to a default
setting or value. Since these directives exist on their own in the
configuration file, their context is that of the whole server. Many
directives will appear in special subsections that limit their scope.
Directives that define subsections are bracketed, XML-like elements.
For example:
<Directory /docs>
Deny From All
</Directory>
This configuration section sets a directive for requests to a single
directory /docs. Many configuration sections
apply to locations of file on the server, such as
<Files>,
<Location>, and
<Directory>. Other configuration sections
define virtual servers (<VirtualHost>) or
contain directives specific to a module
(<IfModule>)
All server configuration can occur in the
httpd.conf file, but you may want to allow
special configuration of only certain parts of your server—you
could let a user configure some aspects of how documents in her
directory are served. By default, Apache looks for
.htaccess files in every directory it serves a
file from. .htaccess may contain any
configuration directives allowed by the server configuration file
with the AllowOverride directive. For example, if
httpd.conf contained the line:
AllowOverride AuthConfig
most of the directives from the user authorization modules
(Auth*) could be used in an
.htaccess file to limit access to the files in
that directory. This is exactly equivalent to using the same
directives within a specified <Directory>
section in httpd.conf.
Since .htaccess files affect the directory they
are in and any subdirectories, they have a cascading affect on
configuration. A directive in a lower-level
.htaccess requires an
AllowOverride from a parent-level
.htaccess to work. This places increased load on
the server, which must search for .htaccess
files and parse them for every request in the current
and parent-level directories. If you want to
completely ignore .htaccess files, use
AllowOverride None in
httpd.conf.