Starting and Stopping the Server

Starting and Stopping the Server

The procedure for starting and stopping the Apache Web server is no different from that of many other server processes. You can use the chkconfig command to set the httpd service to start at boot time.


See Chapter 12 for detailed information on the inner workings of the shell scripts that control starting and stopping daemons and server processes.

The /etc/init.d/httpd shell script accepts any of five command-line arguments. If it is called with the argument start, the httpd script will run one master daemon process (owned by "root"), which will spawn other daemon processes (equal to the number specified by the StartServers directive) owned by the user apache (from the User and Group directives). These processes are responsible for responding to incoming HTTP requests. If called with stop, the server will be shut down as all httpd processes are terminated.

If given a command-line argument of restart, the script will simply execute stop and start procedures in sequence. Using reload as the argument will send the hangup signal (-HUP) to the master httpd daemon, which causes it to reread its configuration files and restart all the other httpd daemon processes. The shell script also supports an argument of status, which will report if the daemon is running and, if it is, the PIDs of the running processes. All other command-line arguments result in an error and cause a usage message to be printed.

The actual server daemon for Apache, /usr/sbin/httpd, supports several command-line arguments, although the default values are typically used. The possible command-line arguments are listed in Table 21-7.

Table 21-7: Command-Line Arguments to httpd



-c directive

Read the configuration files and then process the directive. This may supersede a definition for the directive within the configuration files.

-C directive

Process the directive and then read the configuration files. The directive may alter the evaluation of the configuration file, but it may also be superseded by another definition within the configuration file.

-d directory

Use directory as the ServerRoot directive, specifying where the module, configuration, and log file directories are located.

-D parameter

Define parameter to be used for conditional evaluation within the IfDefine directive.

-f file

Use file as the ServerConfigFile directive, rather than the default of /etc/httpd/conf/httpd.conf.


Display a list of possible command-line arguments.


List the modules linked into the executable at compile time:


Print a verbose list of directives that can be used in the configuration files, along with a short description and the module that contains each directive.


List the configured settings for virtual hosts.


Perform a syntax check on the configuration files. The results will either be:

Syntax OK

or an error notification, for example:

Syntax error on line 118 of /etc/httpd/conf/httpd.conf:


Same as -t, except that there is no check of the DocumentRoot value.


Print the version information:

Server version: Apache/2.0.40

Server built: Feb 11 2003 12:02:50


List the version information and any values defined during compilation:

Server version: Apache/2.0.40

Server built: Feb 11 2003 12:02:50

Server's Module Magic Number: 20020628:0

Architecture: 32-bit

Server compiled with....

-D APACHE_MPM_DIR="server/mpm/prefork"






-D SERVER_CONFIG_FILE="conf/httpd.conf"


Only the single master daemon process is started, and no other httpd processes will be spawned. This should be used only for testing purposes directly from the command line.

Part IV: Red Hat Linux Network and Server Setup