Полезная информация

Webmaster in a Nutshell

Previous Chapter 23 Next
 

23. Apache and NCSA Server Configuration

Contents:
Basic Server Configuration--http.conf
Resource Configuration--srm.conf
Access Configuration--access.conf

Apache is the most widely-used Web server on the Internet. The Apache server was developed from an early version of the NCSA server with the intent of providing further improvement while maintaining compatibility. Apache has now broken ahead as the most popular server, although many sites still use NCSA.

Although this chapter concentrates on documenting Apache, many of the directives listed here are also supported by the NCSA server. For verification of your server's support of a particular directive, we recommend the online documentation. The Apache server and documentation can be obtained from http://www.apache.org. The NCSA server and support information can be obtained from http://hoohoo.ncsa.uiuc.edu.

Apache and NCSA use four separate files to configure their behavior. These are:

httpd.conf

The server configuration file, which specifies the basics of the server's operation.

srm.conf

The resource configuration file, which specifies how the server should treat local resources when responding to a request.

access.conf

The access configuration file, which specifies what operations should be allowed on what files and by whom.

mime.types

The MIME types file, which specifies what MIME types should be associated with what file suffixes (See Chapter 20, Media Types and Subtypes.).

Example copies of each of these files are included with the server software distribution.

In addition to the directives themselves, the configuration files may contain any number of blank lines or comment lines beginning with a hash mark (#). Although directive names are not case-sensitive, we use the case conventions in the default files.

23.1 Basic Server Configuration--http.conf

The server configuration file, named httpd.conf by default, specifies essential information that the server needs in order to run. This includes what machine and port the server is running on, where log files should be written, and how much of the system's resources the server should claim.

The following sections contain the directives that can be used in the httpd.conf file for the Apache and NCSA servers.

AccessConfig

AccessConfig filename

Specifies the location of the access configuration file, either as an absolute path or as a relative path from the ServerRoot directory. For example:

AccessConfig conf/access.conf

Action

Action mime_type cgi_script

Tells the server to execute the specified CGI script whenever a file of the specified MIME type is requested, sending the requested URL as extra path information.

AgentLog

AgentLog filename

Specifies the location of the log file that identifies the client program used for each request, either as an absolute path or as a relative path from the server root. For example:

AgentLog logs/agent_log

Annotation-Server

Annotation-Server servername

Specifies the name of the server to use for public annotations, as supported by the NCSA Mosaic client. This information will then be sent to clients as the value of the Annotations-cgi MIME header in the response. (NCSA only)

AssumeDigestSupport

AssumeDigestSupport

Specifies whether the server should assume MD5 message digest support on the client end.

BindAddress

BindAddress hostname

Specifies the name this server uses when multiple servers are being used for multihoming. Either the IP address or DNS name can be used. For example:

BindAddress www.ora.com

CacheNegotiatedDocs

CacheNegotiatedDocs

Tells the server to allow remote proxy servers to cache negotiated documents. By default, Apache does not allow caching of negotiated documents.

ErrorLog

ErrorLog filename

Specifies the location of the error log file, either an absolute path or relative path to the ServerRoot directory. The default setting is:

ErrorLog logs/error_log

CoreDirectory

CoreDirectory filename

Specifies the directory in which core files should be dumped, as an absolute path or a path relative to the ServerRoot directory. By default, these will be dumped into the ServerRoot directory. (NCSA only)

DNSMode

DNSMode None|Minimum|Standard|Maximum

Controls how often and under what circumstances the server will attempt reverse DNS lookup of the client host. Possible values are:

None

No DNS lookup under any circumstances

Minimum

DNS lookup only for resolving access permissions

Standard

DNS lookup for every request (default)

Maximum

DNS lookup both to get a name for the address, and to confirm that the name can resolve back to that address

(NCSA only)

Group

Group groupname

Specifies the group you want the server process to run as. Either a group name or group ID can be specified; a group ID should be preceded by a number sign (#).

IdentityCheck

IdentityCheck On|Off

Specifies whether the server should attempt to learn the identity of the user for each request by querying the identd process running on the user's machine. By default identity checking is off.

KeepAlive

KeepAlive On|Off

Tells the server to allow persistent connections (default=off). See also KeepAliveTimeOut and MaxKeepAliveRequests.

KeepAliveTimeOut

KeepAliveTimeOut seconds

Specifies the number of seconds to wait for the next request before closing a persistent connection. Used only when persistent connections are enabled with the KeepAlive On setting. The default is 10.

Listen

Listen [ IP_address:] port

Tells the server to listen for requests on the specified port for the specified IP address (if supplied). Overrides BindAddress and Port.

LogDirGroupWriteOk

LogDirGroupWriteOk

Specifies whether the server should be willing to start if any of the log files are in directories that are group writeable. (NCSA only)

LogDirPublicWriteOk

LogDirPublicWriteOk

Specifies whether the server should be willing to start if any of the log files are in directories that are world writeable. (NCSA only)

LogOptions

LogOptions options

Specifies how log information should be written to the various log files. Options are:

Separate

Agent and referer information will be written to separate log files (specified by the AgentLog and RefererLog directives)

Date

Include a date stamp in the separate agent and referer logs

Combined

Agent and referer fields are included in the transfer log at the end of each record

Servername

The server name (from the ServerName directive) is included in the transfer log at the end of each record

(NCSA only)

MaxClients

MaxClients number

Specifies the maximum number of slave processes. The default is 150.

MaxKeepAliveRequests

MaxKeepAliveRequests number

When persistent connections are enabled with KeepAlive On, the MaxKeepAliveRequests directive specifies the number of requests the server will allow per persistent connection. The default is 0 (no limit). (NCSA only)

MaxRequestsPerChild

MaxRequestsPerChild number

Specifies how many requests a slave process may handle during its life. For example:

MaxRequestsPerChild 300

MaxServers

MaxServers number

Defines the maximum number of consecutive slave processes. (NCSA only)

MaxSpareServers

MaxSpareServers number

Specifies the upper range for how many idle slaves the server should keep around at any given time. The default is 10.

MinSpareServers

MinSpareServers number

Specifies the lower range for how many idle slaves the server should keep around at any given time. The default is 5.

PidFile

PidFile filename

Specifies the location of the file into which the server should place its process ID when running in standalone mode, as an absolute path or as a relative path from the ServerRoot directory. The default is:

PidFile logs/httpd.pid

Port

Port number

Specifies the server's port, with a default of 80. Many non-standard ports are assigned to 8001.

ProcessName

ProcessName name

Specifies what name the server should use in process listings (if configured with the SETPROCTITLE flag). (NCSA only)

RefererIgnore

RefererIgnore hostname

Specifies a site to be ignored in the referer log file. (NCSA only)

RefererLog

RefererLog filename

Specifies the location of the refering URL log file. It may be specified either as an absolute path or as a relative path from the ServerRoot directory. The default is:

RefererLog logs/referer_log

ResourceConfig

ResourceConfig filename

Specifies the location of the resource configuration file, as an absolute path or as a relative path from the ServerRoot directory. For example:

ResourceConfig srm.conf

ScoreBoardFile

ScoreBoardFile filename

Specifies the location of the server status file, used by the server to monitor the status of slave processes, as an absolute path or as a relative path from the ServerRoot directory. The default is:

ScoreBoardFile logs/apache_runtime_status

Script

Script method cgi_script

Specifies a CGI script to be executed when a given request method is used. The method can be GET, POST, PUT, or DELETE.

ServerAdmin

ServerAdmin email_address

Specifies the email address to which complaints, suggestions, and questions regarding your server should be sent. Used when the server sends error messages in response to failed requests. This directive has no default. For example:

ServerAdmin webmaster@ora.com

ServerAlias

ServerAlias virtual_hostname real_hostname

Specifies an alternate name for a host.

ServerName

ServerName hostname

Allows you to specify the preferred name for your server machine.

ServerPath

ServerPath pathname

Specifies a pathname for a virtual host--that is, requests for this hostname will be automatically routed to the specified pathname. For use within <VirtualHost> sections.

ServerRoot

ServerRoot directory_path

Specifies the directory in which all the server's associated files reside. This path is used as the root directory when relative paths are specified with other directives. For example:

ServerRoot /usr/local/etc/httpd/

ServerType

ServerType standalone|inetd

Specifies whether your server is to run in standalone mode or under inetd. The default is to run standalone.

<SRMOptions>

<SRMOptions> ...</SRMOptions>

A sectioning directive that can be placed within a <VirtualHost> section in the httpd.conf file. Resource configuration directives specific to the virtual host are placed within a <SRMOptions> section. See <VirtualHost>. (NCSA only)

StartServers

StartServers number

Specifies the initial number of slave processes at server startup. The default is 5.

TimeOut

TimeOut seconds

Specifies the number of seconds to wait before closing a connection. The default is 1200.

TransferLog

TransferLog filename

Specifies the location of the transfer log file, as either an absolute path or a relative path to the ServerRoot directory. The default is:

TransferLog logs/access_log

TypesConfig

TypesConfig filename

Specifies the location of the MIME types file. As with other configuration paths, the location may be given as either an absolute path or a relative path to the ServerRoot directory. The default is:

TypesConfig conf/mime.types

User

User username

Specifies the user and group you want the server process to run as. Either a user name or user ID can be specified; a user ID should be preceded by a number sign (#).

<VirtualHost>

<VirtualHost hostname>...</VirtualHost>

Used when a single server services multiple hostnames. Each hostname is given its own <VirtualHost> directive.

<VirtualHost> has a beginning and ending directive, with other configuration directives for the host entered in between. For Apache, most directives are valid within <VirtualHost> except ServerType, UserId, GroupId, StartServers, MaxSpareServers, MinSpareServers, MaxRequestsPerChild, BindAddress, PidFile, TypesConfig, and ServerRoot. For the NCSA server, most httpd.conf directives are allowed, but srm.conf directives need to be placed within an <SRMOptions> directive embedded in <VirtualHost>.


Previous Home Next
Configuring the Server Book Index Resource Configuration--srm.conf

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell