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.
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!