3.6. Restarts
A
webmaster will sometimes want to kill Apache and restart it with a
new Config file, often to add or remove a virtual host as
people's web sites come and go. This can be done the
brutal way, by running ps -aux
to get Apache's PID, doing kill
<PID> to stop httpd and
restarting it. This method causes any transactions in progress to
fail in an annoying and disconcerting way for logged-on clients. A
recent innovation in Apache allowed restarts of the main server
without suddenly chopping off any child processes that were running.
There are three ways to restart Apache under Unix (see Chapter 2):
-
Kill and reload Apache, which then rereads all its Config files and
restarts:
% kill PID
% httpd [flags]
-
The same effect is achieved with less typing by using the
flag-HUP to kill Apache:
% kill -HUP PID
-
A graceful restart is achieved with the flag-USR1. This rereads the Config files
but lets the child processes run to completion, finishing any client
transactions in progress, before they are replaced with updated
children. In most cases, this is the best way to proceed, because it
won't interrupt people who are browsing at the time
(unless you messed up the Config files):
% kill -USR1
PID
A script to do the job automatically (assuming you are in the server
root directory when you run it) is as follows:
#!/bin/sh
kill -USR1 `cat logs/httpd.pid`
Under Win32 it is enough to open a second
MS-DOS window and type:
apache -k shutdown|restart
See Chapter 2.
| | | 3.5. HTTP Response Headers | | 3.7. .htaccess |
Copyright © 2003 O'Reilly & Associates. All rights reserved.
|
|