Mountain Lion (OS 10.8) is at this time the newest version of the Mac OS and the changes to the Apache web server that ships with it lead many bloggers to misinform readers about controlling the server. Let’s set the record straight.
You want to shut Apache down so that it releases it’s locks on files and so that you can launch Apache in single process mode for easier debugging. While Apache is running you may not be able to edit your web site/app files if the server has locked them. Shutting the server down frees the locks letting you edit or replace files. Then, for easier debugging, you may want to start up Apache consuming one process. To start it up this way you first have to shut it down. These are both good reasons and this article shows you how to shut it down.
Blog after blog say to shut it down use apachectl
sudo apachectl stop
Well, this doesn’t work on Mountain Lion.
As it turns out there is a launch daemon for apache that restarts the stopped apache. To stop apache you have to unload the launch daemon.
sudo /System/Library/LaunchDaemons/launchctl unload org.apache.httpd.plist
To verify that you’ve stopped apache, use ps and grep
ps -ax | grep -i httpd
You should see the console session returned and no other lines with httpd in it. If you issue this several times in a row and the only thing returned is one line for the console sessions, you have successfully stopped the daemon.
Then to start a single process Apache
sudo /usr/sbin/httpd -k start -X -f /etc/apache2/httpd.conf
Once again use the ps and grep command line and you’ll see
/System/Library/LaunchDaemons: ps -ax | grep -i httpd 6098 ttys002 0:00.00 grep -i httpd 6094 ttys003 0:00.02 sudo /usr/sbin/httpd -k start -X -f /etc/apache2/httpd.conf 6095 ttys003 0:00.17 /usr/sbin/httpd -k start -X -f /etc/apache2/httpd.conf /System/Library/LaunchDaemons:
To find out how to do this took considerable time – many blogs say it’s just apachectl and it’s not. Hope this helps.