The LoadModule Directive
The LoadModule
directive instructs the Apache web server software to
load shared object libraries at startup. This should
be the first directive in the configuration file so
the module is available before the web server uses it.
The following is an example:
LoadModule foo_module
modules/mod_foo.so
Please refer to the "modules"
section in this chapter for more information on Apache
modules.
The HostnameLookups
Directive
The Apache web server,
by default, is configured to keep a log of the clients
that access resources on your web site. The log includes
the hostname (i.e. some.remote.host) or just the IP
address (i.e. 32.64.128.16). The value is set to "off"
by default to improve your server performance. Additional
latency is introduced into the server response process
when the web server is required to perform a hostname
"lookup," which translates IP addresses into
domain names. Sites with even moderate loads should
leave this directive off, since hostname lookups can
take considerable amounts of time.
Note: Use a log
analysis tool such as WebTrends to look up hostnames
for IP addresses offline. This is a much more efficient
way to translate IP addresses into domain names.
The following is an example:
HostnameLookups off
For more information,
see the Apache
Web Site Documentation:
The ServerAdmin Directive
The ServerAdmin
directive defines the e-mail address the server includes
in error messages that it returns to the client.
The following is an example:
ServerAdmin webmaster@yourcompany.com
For more information,
see the Apache
Web site documentation:
The ServerRoot Directive
The ServerRoot
directive defines the directory in which the server
resides. The default directory is /usr/local/etc/httpd,
since this directory contains the subdirectories conf
and logs. Relative paths for other configuration
files are defined with respect to the ServerRoot
directory.
The following is an example:
ServerRoot /usr/local/etc/httpd
For more information,
see the Apache
Web Site Documentation:
The ErrorLog Directive
When your web server
encounters an error, it will use the definition specified
in the ErrorLog directive to handle the error.
Typically, a filename is specified to which your web
server appends the error information. If the filename
definition does not begin with a slash ("/"),
then it is assumed to be relative to the ServerRoot.
If the filename begins with a pipe ("|"),
then it is assumed to be a command that is to be spawned
by the web server to handle the error information.
The following is an example:
ErrorLog logs/error_log
For more information,
see the Apache
Web Site Documentation:
The LogFormat Directive
The LogFormat
directive sets the format of the default log file named
by the TransferLog directive. You can also use
this directive to define custom log file format types.
Each log format type is defined by a format declaration
enclosed in quotations followed by an optional identifier
or a nickname. Examples of some LogFormat directives
are included below. (For more information about using
log formats effectively, please refer to the "Managing
Server Log Files" section in this chapter.)
The format declaration
member of each LogFormat directive can contain
literal characters copied into the log files, and ‘%'
directives that are replaced in the log file. A sample
of some of the ‘%' directives are shown below.
(A complete list can be found on the Apache web site.)
- %b: Bytes sent, excluding
HTTP headers.
- %f: Filename
- %h: Remote host
- %r: First line of
request
- %s: Status. For requests
that got internally redirected, this is status of
the *original* request --- %>s for the last.
- %t: Time, in common
log format time format
- %u: Remote user
Examples:
Logformat "format
declaration" identifier
LogFormat "%h %l %u %t \"%r\" %>s
%b \"%{Referrer}i\" \"{User-Agent}i\""
combined
LogFormat "%h %l %u %t \"%r\" %>s
%b" common
LogFormat "%{Referrer}i -> %U" referrer
LogFormat "%{User-Agent}I" agent
For more information,
see the Apache Documentation on Logformat
and Formats:
The TransferLog Directive
The TransferLog
directive is used to identify the location of a file
that will contain a record of all requests made to your
web server. If you are using the CustomLog directive
to define the format of your log files, the format of
your TransferLog file will be defined by the
most recent LogFormat directive (or Combined
Log Format if no other default format has been specified).
If you would like entries in your transfer log to be
formatted with the Common Log Format, you will need
to create a custom LogFormat definition. You
can also process your Transfer Log entries with an external
application by defining your TransferLog using
a file pipe ("|"). An example is included
below. (For more information, please refer to the "Managing
Server Log Files" section in Chapter
8.)
The following is an example:
TransferLog logs/access_log
Or:
TransferLog "|rotatelogs
/www/logs/access_log 86400"
For more information,
see the Apache Web Site Documentation on TransferLog
and CustomLog:
The RefererLog Directive
The RefererLog directive is used to identify the location of a file
that will contain a record of all referrer information
(i.e. information about web sites that link to and "referred"
users to your web site). By default, your server is
configured in the combined log format. As such, the
referrer information is included in the access_log.
If you want a separate log for referrer information,
see "Changing LogFormat" below.
The following is an example:
RefererLog logs/referer_log
For more information,
see the Apache Web Site Documentation on RefererLog:
The AgentLog Directive
The AgentLog directive
is used to identify the location of a file that contains
a record of all browser agent information. By default,
your server is configured in the combined log format.
As such, the agent information is included in the access_log.
If you want a separate log for agent information, see
"Changing LogFormat" below.
The following is an example:
AgentLog logs/agent_log
For more information,
see the Apache Web Site Documentation on AgentLog:
Changing LogFormat
You can change the web
server log file format to the common log format (separate
log files for the access, agent, and referrer data)
by modifying your web server configuration file (~/www/conf/httpd.conf)
like this:
# common log format
LogFormat "%h %l %u %t \"%r\" %>s
%b"
# combined log format
#LogFormat "%h %l %u %t \"%r\" %>s
%b \"%{Referrer}i\" \"%{User-Agent}i\""
# The location of the
access logfile
# If this does not start with /, ServerRoot is prepended
to it.
TransferLog logs/access_log
# If you would like
to have a separate agent and referrer logfile
# uncomment the following directives.
ReferrerLog logs/referrer_log
AgentLog logs/agent_log
You can also define your
own log format by modifying the LogFormat directive
above. After making the changes above, be sure to restart
your Virtual Server web server.
The ServerName Directive
The ServerName
directive sets the hostname of the web server.
The following is a usage
example:
ServerName some.domain.name
For more information,
see the Apache Web Site Documentation on ServerName:
The KeepAlive Directive
The KeepAlive
extension to HTTP, as defined by the HTTP/1.1 draft,
allows persistent connections. These long-lived HTTP
sessions allow multiple requests to be sent over the
same TCP connection and in some cases have been shown
to result in an almost 50% speedup in latency times
for HTML documents with multiple images. The KeepAlive
directive enables or disables KeepAlive support.
Set the value of this directive to "on"
in order to enable persistent connections. Set the value
of the directive to "off" to disable KeepAlive support. The maximum number of requests
that you would like the web server to support per connection
is defined with the MaxKeepAliveRequests directive.
The following is an example:
KeepAlive on
For more information,
see the Apache Documentation for KeepAlive
Directive as well as the White
Paper document on KeepAlive:
The MaxKeepAliveRequests
Directive
The MaxKeepAliveRequests
directive limits the number of requests allowed per
connection when KeepAlive is on. If it is set to 0,
unlimited requests will be allowed. It is recommended
that this setting be kept to a high value for maximum
server performance.
The following is an example:
MaxKeepAliveRequests
100
For more information,
see the Apache Web Site documentation on the Max
KeepAliveRequests Directive:
The KeepAliveTimeout
Directive
The KeepAliveTimeout
directive defines the number of seconds the web server
waits for a subsequent request before closing the connection
to the remote host.
The following is an example:
KeepAliveTimeout 15
For more information,
see the Apache Web Site Documentation on the KeepAliveTimeOut
Directive:
The MaxRequestsPerChild
Directive
The MaxRequestsPerChild
directive sets the limit on the number of requests that
an individual child server process will handle. After
MaxRequestsPerChild requests, the child process
will die. If MaxRequestsPerChild is 0,
then the process will never expire. Setting MaxRequestsPerChild
to a non-zero limit has two beneficial effects:
- It limits the amount
of memory that process can consume by (accidental)
memory leakage.
- It helps reduce the
number of processes when the server load reduces by
giving processes a finite lifetime.
The following is an example:
MaxRequestsPerChild
0
For more information,
see the Apache Web Site Documentation on the MaxRequestsPerChild
Directive:
The VirtualHost Directive
The VirtualHost
directive allows you to configure your web server to
subhost multiple domain names.
The following is an example:
<VirtualHost the-subhost.domain.name>
ServerAdmin webmaster@the-subhost.domain.name
DocumentRoot /usr/local/etc/httpd/vhosts/subhost-dir
ServerName the-subhost.domain.name
ErrorLog logs/subhost-error_log
TransferLog logs/subhost-access_log
</VirtualHost>
For more information,
see "Understanding
Virtual Hosting" in Chapter
3.
|