MacOS Apache – Enabling Service on Mac OS X Mountain Lion

apachemacos

This is my first Mac, it's Mountain Lion, and I know how to enable Apache through Preferences -> Sharing -> Web Sharing, but how the hell do I do it in Mountain Lion?

I find that that button no longer exists, so what's the Ternimal command to turn it on manually?

Best Answer

To start apache
sudo apachectl start

This will give you a basic Apache server with a DocumentRoot at /Library/WebServer/Documents/

You can enable things like PHP and virtualhosts by making use of the configuration file, which must be edited as root:
/etc/apache2/httpd.conf

Restart the apache server (like after editing the config file) with
sudo apachectl graceful

Stop the apache server
sudo apachectl graceful-stop

I believe in order to use user directories (like allowing ~/Sites/ to be accessed at http://localhost/~username/) or to get httpd to run at startup, you will need to do a little tweaking. I unfortunately can't test how easy it is to get the full functionality of the previous versions back since my Apache configs did not come from a "clean" 10.8 install.