Starting Apache

Invoking Apache

The httpd program is either invoked by the Internet daemon inetd each time a connection to the HTTP service is made, or alternatively it may run as a daemon which executes continuously, handling requests. Whatever method is chosen, the ServerType directive must be set to tell the server how it is to run.

Command line options

The following options are recognised 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/etc/httpd.
-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.
-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 then exit.
-?
Print a list of the httpd options, and then exit.

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, or the -d command line flag. 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/acces.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

pid file

On daemon startup, it 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; A HUP signal causes the daemon to re-read its configuration files and a TERM signal causes it to die gracefully.

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, logs/error_log by default. 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, logs/access_log by default. The filename can be set using a TransferLog directive; different transfer logs can be set for different virtual hosts.
Home Index