[APACHE DOCUMENTATION]

Apache HTTP Server Version 1.3

Starting Apache

Invoking Apache

On Unix, the httpd program is usually run as a daemon which executes continuously, handling requests. It is possible to invoke Apache by the Internet daemon inetd each time a connection to the HTTP service is made (use the ServerType directive) but this is not recommended.

On Windows, Apache is normally run as a service on Windows NT, or as a console application on Windows 95. See also running Apache for Windows.

Command line options

The following options are recognized on the httpd command line:
-d serverroot
Set the initial value for the ServerRoot variable to serverroot. This can be overridden by the ServerRoot command in the configuration file. The default is /usr/local/apache on Unix, /apache on Windows and /os2httpd on OS/2.
-D name
Define a name for use in in IfDefine directives. This option can be used to optionally enable certain functionality in the configuration file, or to use a common configuration for several independent hosts, where host specific information is enclosed in <IfDefine> sections.
-f config
Execute the commands in the file config on startup. If config does not begin with a /, then it is taken to be a path relative to the ServerRoot. The default is conf/httpd.conf.
-C "directive"
Process the given apache "directive" (just as if it had been part of a configuration file) before actually reading the regular configuration files.
-c "directive"
Process the given apache "directive" after reading all the regular configuration files.
-X
Run in single-process mode, for internal debugging purposes only; the daemon does not detach from the terminal or fork any children. Do NOT use this mode to provide ordinary web service.
-v
Print the version of httpd and its build date, and then exit.
-V
Print the base version of httpd, its build date, and a list of compile time settings which influence the behavior and performance of the apache server (e.g., -DUSE_MMAP_FILES), then exit.
-L
Give a list of directives together with expected arguments and places where the directive is valid, then exit. (Apache 1.3.4 and later. Earlier versions used -l instead).
-l
Give a list of all modules compiled into the server, then exit. (Apache 1.3.4 and later. Earlier versions used -h instead).
Give a list of directives together with expected arguments and places where the directive is valid, then exit. (Apache 1.2 to 1.3.3. Later versions use -L instead).
-h
Print a list of the httpd options, then exit. (Apache 1.3.4 and later. Earlier versions used -? instead).
Give a list of all modules compiled into the server, then exit. (Up to Apache 1.3.3. Later versions use -l instead).
-S
Show the settings as parsed from the config file (currently only shows a breakdown of the vhost settings) but do not start the server. (Up to Apache 1.3.3, this option also started the server).
-t
Test the configuration file syntax (i.e., read all configuration files and interpret them) but do not start the server. If the configuration contains errors, display an error message and exit with a non-zero exit status, otherwise display "Syntax OK" and terminate with a zero exit status.
-k option
Windows only: signal Apache to restart or shutdown. option is one of "shutdown" or "restart". (Apache 1.3.3 and later).
-?
Print a list of the httpd options, and then exit (up to Apache 1.3.3. Later version use -h instead).

Configuration files

The server will read three files for configuration directives. Any directive may appear in any of these files. The the names of these files are taken to be relative to the server root; this is set by the ServerRoot directive, the -d command line flag, or (on Windows only) the registry (see Running Apache for Windows). Conventionally, the files are:
conf/httpd.conf
Contains directives that control the operation of the server daemon. The filename may be overridden with the -f command line flag.
conf/srm.conf
Contains directives that control the specification of documents that the server can provide to clients. The filename may be overridden with the ResourceConfig directive.
conf/access.conf
Contains directives that control access to documents. The filename may be overridden with the AccessConfig directive.
However, these conventions need not be adhered to.

The server also reads a file containing mime document types; the filename is set by the TypesConfig directive, and is conf/mime.types by default.

Log files

security warning

Anyone who can write to the directory where Apache is writing a log file can almost certainly gain access to the uid that the server is started as, which is normally root. Do NOT give people write access to the directory the logs are stored in without being aware of the consequences; see the security tips document for details.

pid file

On startup, Apache saves the process id of the parent httpd process to the file logs/httpd.pid. This filename can be changed with the PidFile directive. The process-id is for use by the administrator in restarting and terminating the daemon: on Unix, a HUP or USR1 signal causes the daemon to re-read its configuration files and a TERM signal causes it to die gracefully; on Windows, use the -k command line option instead. For more information see the Stopping and Restarting page.

If the process dies (or is killed) abnormally, then it will be necessary to kill the children httpd processes.

Error log

The server will log error messages to a log file, by default logs/error_log on Unix or logs/error.log on Windows and OS/2. The filename can be set using the ErrorLog directive; different error logs can be set for different virtual hosts.

Transfer log

The server will typically log each request to a transfer file, by default logs/access_log on Unix or logs/access.log on Windows and OS/2. The filename can be set using a TransferLog directive or additional log files created with the CustomLog directive; different transfer logs can be set for different virtual hosts.

Apache HTTP Server Version 1.3

Index