Changing user httpd DocumentRoot in OS X

# 16 Mar 2011

While testing a locally running web application in OS X 10.6.6, I discovered that DocumentRoot appears to be set incorrectly. I wasn’t able to refer to a file like /Users/username/Sites/style.css as /style.css in the web app source.

If you have Web Sharing turned on, each user’s httpd DocumentRoot is not automatically set to /Users/username/Sites, as I expected.

But each user does have there own personal httpd.conf file in /private/etc/apache2/users.

Find yours, then add the following, replacing username with your own:

DocumentRoot /Users/username/Sites

Toggle Web Sharing off/on, and it should be fixed.