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?
1 Answer
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
sudorequests 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 startthe launch daemon seems to be activated again after restart.Till– Till2014-02-04 08:14:53 +00:00Commented Feb 4, 2014 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– jaume2014-02-04 08:27:43 +00:00Commented Feb 4, 2014 at 8:27 -
I tried
-wbefore, same result. Here is the output: pastebin.com/h14t8fEvTill– Till2014-02-04 15:05:39 +00:00Commented Feb 4, 2014 at 15:05 -
Thanks, does
sudo launchctl1 ...return an error message? Could you post the output ofgrep apache /var/log/com.apple.launchd/launchd-shutdown.system.logandsudo grep apache /var/log/system.log?jaume– jaume2014-02-04 15:56:53 +00:00Commented Feb 4, 2014 at 15:56 -
Yes:
sudo: launchctl1: command not foundand here is the output: pastebin.com/raw.php?i=zxKvYV4iTill– Till2014-02-05 07:33:14 +00:00Commented Feb 5, 2014 at 7:33