2.6 Apache Configuration Basics
Apache configuration is mostly determined at start-up, when the server reads httpd.conf (and any included files). Configuration data, including resources derived from them by a module (e.g., by opening a file), are stored on each module's configuration records.
Each module has two configuration records, either or both of which may be null (unused):
- The per-server configuration is stored directly on the server_rec, so there is one instance per virtual host. The scope of per-server directives is controlled by <VirtualHost> containers in httpd.conf, but other containers such as <Location>, <Directory>, and <Files> will be ignored.
- The per-directory configuration is stored indirectly and is available to modules via the request_rec object in the course of processing a request. It is the opposite of per-server configuration: Its scope is defined by containers such as <Location>, <Directory>, and <Files>.
To implement a configuration directive, a module must supply a function that will recognize the directive and set a field in one of the configuration records at system start-up time. After start-up, the configuration is set and should not be changed. In particular, the configuration records should generally be treated as read-only while processing requests (or connections). Changing configuration data during request processing violates thread safety (requiring use of programming techniques such as locking) and runs a high risk of introducing other bugs due to the increased complexity. Apache provides a separate configuration record on each conn_rec and request_rec for transient data.
Chapter 9 describes working with configuration records and data.