Problem with Apache SSI on OSX

Using Server-Side Includes (SSI) can be a useful way to manage repeating elements in your web pages if you don’t need a full dynamic solution like PHP. For a simple site with repeating header and footer elements, it could be the answer, especially since you can manage ‘current link’ highlighting with CSS.

If you want to use SSI and you are using a Mac, the chances are you’ll want to use the version of the Apache web server that comes built into OSX. That way you can see how the site runs during the build, before uploading it to the server. It’s a fairly straightforward process and there are some tutorials out there which guide you through it all. Basically you need to edit a couple of lines in your httpd.conf file and turn on web sharing in System preferences > sharing, then you are able to browse to your own web server on your own machine using a local URL

I tried all this and the includes just weren’t working. I rechecked the httpd.conf file, turned the web server off and on again a few times, and still nothing. It turns out the problem, which didn’t seem to be mentioned in any of the (admittedly fairly old) tutorials I was reading, is that in OSX the httpd.conf file is actually spread over 2 different places. The main file itself (/etc/httpd/httpd.conf) includes another setup file which is located in /private/etc/httpd/users/. This allows you to set up Apache settings on a per user basis. So you need to make sure you enable includes in the tag in this file as well. Add it to the Options line, so you have something like this:

<Directory "/Users/ben/Sites/">
    Options Indexes MultiViews Includes
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Leave a comment