Configuring Apache to use a Dropbox folder as a DocumentRoot (Mac OS X)

I’ve been using dropbox for a few years now and I find it to be a terrific tool, specially if you have more than one workstation.

I just got a new machine for the office and still have a laptop that I use to work on the go or at home. So being able to not worry when I leave the office about if I should take some files with me it’s very important and relaxing.

So, since I do a lot of web development it was normal to me that I should use a Dropbox folder my apache DocumentRoot, and since every time I get a new machine I spend 30 mins figuring out how to make it work I decided to make this little guide.

In my setup I am using ~/Dropbox/Sites as my document root, but feel free to change it to whatever fits better your needs.

Okay, the first thing we have to do is to specify  the new DocumentRoot directory. So open up a terminal and fire up!

sudo vi /etc/apache2/httpd.conf

Look for DocumentRoot (not the inside MACOSXSERVER) and change it to whatever you want the path to be. In my case “/Users/Ares/Dropbox/Sites” then look for:

# This should be changed to whatever you set DocumentRoot to.
<Directory “/Users/Ares/Dropbox/Sites”>

and change the directory to the same as your DocumentRoot.

you can then save an exit.


Now, in OS X , apache runs under the user _www with group _www. So right now, due to permissions apache would not be able to read your document root. There are a few approaches we could take here to grant apache access to the DocumentRoot such as just giving everything under /Users a 777 permission, but this is not optimal so I opted for adding the user _www to the group staff since “staff” already has reading permissions to your user directory anyways. So, in your terminal issue the following command:

sudo dseditgroup -o edit -a _www -t user staff

Now, the last thing you need to do is to grant “read and write” rights to the group under your  dropbox folder. It is important to note that the group needs access to every folder down the way to dropbox folder so you will need to do something like

sudo chmod 755 /Users
 sudo chmod 755 /Users/your-username
 chmod 750 /Users/your-username/Dropbox
 chmod -R 755 /Users/your-username/Dropbox/Sites

once this is done all you need to do is restart apache with

sudo apachectl graceful

This should get rid of the “Forbidden” error apache would throw if you just change your httpd.conf file without changing your permissions.

Happy sync’in and programming!

2 comments on “Configuring Apache to use a Dropbox folder as a DocumentRoot (Mac OS X)

  1. Fabiano Coelho on said:

    What about MySQL?
    Do you always dump the tables and import them between machines ?

    • Yes, I general that is what I do. I’ve thought about installing MySQL inside Dropbox but I need to do more research if there are any dependencies or library discrepancies between systems.

      That’s a good weekend project.

Leave a Reply

Your email address will not be published. Required fields are marked *


34,707 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" extra="">