Syndicate

How To Disable and Enable default Apache httpd on Mac OS X

Author: 
Sergio
Sergio's picture

The only command you should use is:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

This will stop a running instance of Apache, and record that it should not be restarted. It modifies the registry in /private/var/db/launchd.db/com.apple.launchd/overrides.plist
Please don't confuse this with Windows Registry. Basically, it's a XML file marked that daemon should be disabled and not started after reboot.

To enable auto start of default Apache use the following command: sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Apache Verbose mode start/stop:
sudo bash -x /usr/sbin/apachectl -k stop

To check if it's running use this command: ps aux | grep httpd

Basically, if it's shows just one line the Apache is stopped.

Some useful notes about launchctl command:
1. launchctl is an OSx program that interfaces with launchd, which is a daemon manager.
2. unload tells launchctl to unload a specified configuration file.
3. -w tells launchctl to override a disabled key, basically this will force the file to be marked as disabled.
4. /System/Library/LaunchDaemons/org.apache.httpd.plist is the file that we are unloading.

Enjoy!