I'm on a fresh 10.9 install and the default Apache server is org.apache.httpd: Already loaded
after each startup. Is there a way to disable that autostart?
OS X provides launchctl
to control which daemons are started at boot time.
To stop and disable Apache:
- Open Terminal
Type the following command (type your login password when
sudo
requests it):sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
A few words on launchctl
's -w
option
The -w
option is the silver bullet for stopping/disabling Apache. It tells launchctl
to do its job regardless of any configuration settings that would otherwise prevent it from unloading the service, as explained in man launchctl
:
-w Overrides the Disabled key and sets it to false or true for the load and
unload subcommands respectively. In previous versions, this option would
modify the configuration file. Now the state of the Disabled key is stored
elsewhere on- disk in a location that may not be directly manipulated by any
process other than launchd.
(It turns out that, in OS X Mavericks (10.9), "elsewhere on-disk" is /private/var/db/launchd.db/com.apple.launchd/overrides.plist
.)
The -w
option is indispensable if you started Apache with apachectl start
: as explained in this Superuser answer. apachectl
not only starts Apache but also modifies /private/var/db/launchd.db/com.apple.launchd/overrides.plist
like this:
<key>org.apache.httpd</key>
<dict>
<key>Disabled</key>
<false/>
</dict>
In this particular case you can also use apachectl
:
sudo apachectl stop
to stop Apache and to set Disabled
to true
.
-
I tried that, but each time I run
sudo apachectl start
the launch daemon seems to be activated again after restart. – Till Feb 4 '14 at 8:14 -
Try with
-w
:sudo launchctl -w unload ...
. If it doesn't help, could you post the output ofps -ef|grep httpd|grep -v grep
? – jaume Feb 4 '14 at 8:27 -
-
Thanks, does
sudo launchctl1 ...
return an error message? Could you post the output ofgrep apache /var/log/com.apple.launchd/launchd-shutdown.system.log
andsudo grep apache /var/log/system.log
? – jaume Feb 4 '14 at 15:56 -
Yes:
sudo: launchctl1: command not found
and here is the output: pastebin.com/raw.php?i=zxKvYV4i – Till Feb 5 '14 at 7:33