After updating my Macs to Mac OS X 10.8 (Mountain Lion), I discovered that Apple removed the “Web Sharing” option from the “Sharing control panel. This option essentially turns your local copy of Apache on or off. While this change didn’t happen to make Apple’s list of “200+ New Features” of Mountain Lion, they do at least discuss the change briefly in a Tech Note entitled “OS X Mountain Lion: Options for web sharing”.

In addition to removing the GUI control for Apache, some other configurations now prevent Apache from loading custom virtual hosts and SSL settings by default. As a developer who works locally, I had several, so when my local sites didn’t load, I was initially a little concerned. However, after some tinkering and Googling, I have managed to get my sites up and running again. Here’s what I did:

Turning Apache On or Off

First issue to tackle is turning Apache on or off. If you don’t use the command line, and simply want the ability to turn Apache on or off through the Preferences again, then you can install Tyler Hall’s “Web Sharing preference pane”.
Download it, then double-click the file to install it. You’ll then see it in your System Preferences on the last row. It features a simple ON/OFF switch.

If you prefer the command line, then you can turn Apache on or off by issuing the following commands:

To turn Apache ON:

sudo apachectl start

To turn Apache OFF:

sudo apachectl stop

To RESTART Apache (turn it off then back on with one command):

sudo apachectl restart

Note, I’ve seen some people say restart didn’t work for then but for me it has worked just fine.

Re-Enabling Your Existing Virtual Hosts

Most of my sites all run locally under their own domain name. So for example, if I enter,, the browser will know to load the index file
from /Library/WebServer/Documents/someproject.

Once I updated to Mountain Lion, all these custom domains stopped working. Two things happened here. First it seems that with the update, Apple modified my /etc/apache2/httpd.conf file, by commenting out the line that loads the file with my virtual hosts settings.

To fix this open this file in either the terminal or a text editor (I use TextMate), and make the following changes:

First, load your custom virtual hosts settings again by uncommenting (remove the first # sign) from this line (Line 477):

Include /private/etc/apache2/extra/httpd-vhosts.conf

Next, if you want to use the built-in PHP server, then uncomment this line (Line 117):

LoadModule php5_module libexec/apache2/

Finally, if are using any custom SSL certificates, then you will probably need to uncomment this (Line 489):

Include /private/etc/apache2/extra/httpd-ssl.conf

If you don’t use any local SSL certificates then that is all you need to do. However if you are, there is one more change. In earlier versions of the OS, all my security certificates lived in /etc/httpd/ssl.key. Now there isn’t a “httpd” directory so they are now all in /etc/ssl.key. This change must be updated in your httpd-ssl.conf file and any other ssl conf files you may have created manually.

The easiest way to check this is to issue the following command to check your Apache config’s syntax:

sudo apachectl -t

If you have issues, you may see a response like this:

Syntax error on line 99 of /private/etc/apache2/extra/httpd-ssl.conf: SSLCertificateFile: file '/etc/httpd/ssl.key/my-custom-cert.crt' does not exist or is empty

Open that httpd-ssl.conf file in the terminal or via a text editor like TextMate, and update the file path by removing the “httpd” from the path. For example, my updated path now looks like:


I had several custom conf files, so I just repeated this step over a few times to catch them all. You will probably find that you have 2 paths to change in each situation, one for the crt file and one for the key file. They will typically be very close to each other.

Hopefully this will get you up and running.


TidBITS: How to Bring Web Sharing Back to Mountain Lion

“Fixing Virtual Hosts and Web Sharing in Mountain Lion”

ColdFusion 9: Regular Expression Syntax

Web Sharing in OS X Mountain Lion

« »