1--- docs/man/apachectl.8.orig	2005-09-20 07:54:17.000000000 -0700
2+++ docs/man/apachectl.8	2008-07-15 13:09:46.000000000 -0700
3@@ -62,13 +62,13 @@
4  
5 .TP
6 start
7-Start the Apache httpd daemon\&. Gives an error if it is already running\&. This is equivalent to apachectl -k start\&.  
8+Loads the org\&.apache\&.httpd launchd job\&.
9 .TP
10-stop
11-Stops the Apache httpd daemon\&. This is equivalent to apachectl -k stop\&.  
12+stop, graceful-stop
13+Unloads the org\&.apache\&.httpd launchd job\&.
14 .TP
15-restart
16-Restarts the Apache httpd daemon\&. If the daemon is not running, it is started\&. This command automatically checks the configuration files as in configtest before initiating the restart to make sure the daemon doesn't die\&. This is equivalent to apachectl -k restart\&.  
17+restart, graceful
18+Unloads, then loads the org\&.apache\&.httpd launchd job\&.
19 .TP
20 fullstatus
21 Displays a full status report from mod_status\&. For this to work, you need to have mod_status enabled on your server and a text-based browser such as lynx available on your system\&. The URL used to access the status report can be set by editing the STATUSURL variable in the script\&.  
22@@ -76,12 +76,6 @@
23 status
24 Displays a brief status report\&. Similar to the fullstatus option, except that the list of requests currently being served is omitted\&.  
25 .TP
26-graceful
27-Gracefully restarts the Apache httpd daemon\&. If the daemon is not running, it is started\&. This differs from a normal restart in that currently open connections are not aborted\&. A side effect is that old log files will not be closed immediately\&. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them\&. This command automatically checks the configuration files as in configtest before initiating the restart to make sure Apache doesn't die\&. This is equivalent to apachectl -k graceful\&.  
28-.TP
29-graceful-stop
30-Gracefully stops the Apache httpd daemon\&. This differs from a normal stop in that currently open connections are not aborted\&. A side effect is that old log files will not be closed immediately\&. This is equivalent to apachectl -k graceful-stop\&.  
31-.TP
32 configtest
33 Run a configuration file syntax test\&. It parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error\&. This is equivalent to apachectl -t\&.  
34  
35--- support/apachectl.in.orig	2012-01-31 19:47:28.000000000 -0800
36+++ support/apachectl.in	2013-11-12 14:00:54.000000000 -0800
37@@ -66,6 +66,19 @@ ULIMIT_MAX_FILES="@APACHECTL_ULIMIT@"
38 # --------------------                              --------------------
39 # ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||
40 
41+LAUNCHCTL="/bin/launchctl"
42+LAUNCHD_JOB="/System/Library/LaunchDaemons/org.apache.httpd.plist"
43+
44+run_launchctl() {
45+    if [ $UID != 0 ]; then
46+        echo This operation requires root.
47+        exit 1
48+    fi
49+
50+    $LAUNCHCTL $@
51+}
52+
53+
54 # Set the maximum number of file descriptors allowed per child process.
55 if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
56     $ULIMIT_MAX_FILES
57@@ -76,9 +89,18 @@ if [ "x$ARGV" = "x" ] ; then 
58     ARGV="-h"
59 fi
60 
61-case $ACMD in
62-start|stop|restart|graceful|graceful-stop)
63-    $HTTPD -k $ARGV
64+case $ARGV in
65+start)
66+    run_launchctl load -w $LAUNCHD_JOB
67+    ERROR=$?
68+    ;;
69+stop|graceful-stop)
70+    run_launchctl unload -w $LAUNCHD_JOB
71+    ERROR=$?
72+    ;;
73+restart|graceful)
74+    run_launchctl unload -w $LAUNCHD_JOB 2> /dev/null
75+    run_launchctl load -w $LAUNCHD_JOB
76     ERROR=$?
77     ;;
78 startssl|sslstart|start-SSL)
79@@ -91,11 +113,9 @@ configtest)
80     $HTTPD -t
81     ERROR=$?
82     ;;
83-status)
84-    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
85-    ;;
86-fullstatus)
87-    $LYNX $STATUSURL
88+status|fullstatus)
89+    echo Go to $STATUSURL in the web browser of your choice.
90+    echo Note that mod_status must be enabled for this to work.
91     ;;
92 *)
93     $HTTPD "$@"
94