/etc/init.d/apache2 is a shell script and is not the same as the Apache server located in /usr/sbin. That is, /usr/sbin/apache2 is the program executable file (the server); /etc/init.d/apache2 is a shell script that uses another shell script, apache2ctl, to control the server. See Chapter 15 for a description of some service scripts under /etc/init.d and how the scripts are used to manage services such as apache2.

You can use the /etc/init.d/apache2 script and the following options to control the web server:

• start The system uses this option to start the web server during bootup. You, through sudo, can also use this script to start the server.

• stop The system uses this option to stop the server gracefully. You should use this script, rather than the kill command, to stop the server.

• reload You can use this option to send the hup signal to the apache2 server to have it reread the configuration files after modification.

• restart This option is a convenient way to stop and then immediately start the web server. If the apache2 server isn't running, it is started.

• condrestart The same as the restart parameter, except that it restarts the apache2 server only if it is actually running.

• status This option indicates whether the server is running; if it is, it provides the various PIDs for each instance of the server.

For example, to check on the status of your server, use the command sudo /etc/init.d/apache2 status

This prints the following for me:

apache2 (pid 15997 1791 1790 1789 1788 1787 1786 1785 1784 1781) is running...

This indicates that the web server is running; in fact, 10 instances of the server are currently running in this configuration.

In addition to the previous options, the apache2 script also offers these features:

• help Prints a list of valid options to the apache2 script (which are passed onto the server as if called from the command line).

• configtest A simple test of the server's configuration, which reports status ok if the setup is correct. You can also use apache2's -t option to perform the same test, like this:

audo apache2 -t

• fullstatus Displays a verbose status report.

• graceful The same as the restart parameter, except that the configtest option is used first and open connections are not aborted.

Use the reioad option if you are making many changes to the various server configuration files. This saves time when you are stopping and starting the server by having the system simply reread the configuration files.


Was this article helpful?

0 0

Post a comment