12

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?

13

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.

  • Awesome! This is more than enough! Thanks a lot. :) If you do find out how to configure the use of ~/Sites/ then please tell me. ;) – greduan Oct 5 '12 at 2:44
  • 1
    Some preliminary poking seems to indicate it has to do with making sure mod_userdir is active and that /etc/apache2/extras/httpd-userdir.conf is being properly imported at the end of the main configuration file. If ~/Sites already exists, that may be all you have to do... – NReilingh Oct 5 '12 at 3:04
  • OK, I'll check it out then, thanks for all your help. :) – greduan Oct 5 '12 at 13:13
  • The only thing that changed when I unpgraded was my custom *.conf directory was nixed from the /private/etc/apache2/httpd.conf file. I ran />httpd -S from Terminal and it pointed out the error of my ways. – Shanimal Oct 5 '12 at 14:46
4

To make it permanent you can do this:

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

the '-w' option sets it to restart the service on rebooting etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .