Answers:
OS X提供launchctl了控制在引导时启动哪些守护程序的功能。
要停止并禁用Apache:
键入以下命令(在sudo请求时输入您的登录密码):
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
关于launchctl的-w选项
该-w选项是停止/禁用Apache的灵丹妙药。它会告诉launchctl您执行其工作,而不考虑任何其他配置设置,否则将阻止其卸载服务,如中所述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.
(事实证明,在OS X Mavericks(10.9)中,“磁盘上的其他位置”是/private/var/db/launchd.db/com.apple.launchd/overrides.plist。)
该-w选项是必不可少的,如果你开始的Apache apachectl start:如解释在这个超级用户答案。apachectl不仅可以启动Apache,还可以进行如下修改/private/var/db/launchd.db/com.apple.launchd/overrides.plist:
<key>org.apache.httpd</key>
<dict>
<key>Disabled</key>
<false/>
</dict>
在这种情况下,您还可以使用apachectl:
sudo apachectl stop
停止Apache并设置Disabled为true。
-w:sudo launchctl -w unload ...。如果没有帮助,您可以发布输出ps -ef|grep httpd|grep -v grep吗?
-w过,同样的结果。输出如下:pastebin.com/h14t8fEv
sudo launchctl1 ...返回错误消息?你能后的输出grep apache /var/log/com.apple.launchd/launchd-shutdown.system.log和sudo grep apache /var/log/system.log?
sudo: launchctl1: command not found这是输出:pastebin.com/raw.php?i=zxKvYV4i
sudo apachectl start启动守护程序后,它似乎都在重新启动后再次被激活。