Serving pages from Dropbox

This post was written 12 years ago.
Tue, 13 Nov 2012

Adventures of a newbie server admin Part 1

About a year ago I started using eatStatic blogging engine for this blog, and it's been working really well. Apart from not actually writing much, the only thing that was bugging me is that I'd not set it up to work with files from a Dropbox (as does the original). As I have recently started to run my own vps and am now moving sites over, I thought it was time to give it a try!

To achieve my objective seemed at first ridiculously easier than I'd thought, but then actually proved to be very tricky and took me a long time to figure out. The crucial thing proved to be giving the 'apache user' (www-data on Ubuntu) permission to access the files in the Dropbox folder.

Edit 7 Dec 2012: I have since noticed that actually in most cases it is as simple as creating a symlink. I think my blog was a special case as the blog is in a subdirectory of my website, and because of that my posts are below siteroot level, whereas in the default setup they would be on the same level. This is my assumption, I have not systematically tested that yet.

But here is a quick walk-through of the process.

The first step was to install Dropbox on the server.

Then I made a symlink, from where the posts are meant to reside in the blogging engine, to the Dropbox folder.

$ ln -s ~/Dropbox/Public/posts ~/[..]/data/posts

And that would be it, right? Only that it doesn't work that way. If you try to go to the 'data' directory in the browser, it will show the subdirectories of that folder, but not 'posts'. I tried a lot then with sharing the directory from the Dropbox web interface (but of course that is only with individual users), and moving it into the Public directory, but all that didn't help.

I think I also tried to change permission on all the files in the folder (chmod 777) and that didn't help either. It turned out that they actually had to be owned by www-data or a group that www-data was part of. So eventually I created a group that I called 'dbowners' and added my ssh user and www-data to it.

$ addgroup dbowners
$ adduser katja dbowners
$ adduser www-data dbowners

And then:

$ chown -R katja:dbowners ~/Dropbox/
$ chmod -R u+rw ~/Dropbox/
$ chown -R katja:dbowners ~/.dropbox
$ chmod -R u+rw ~/.dropbox

I don't know if that's the best way to do it, but it worked! So now I will just move this file over to my Dropbox..


This post was written 12 years ago, which in internet time is really, really old. This means that what is written above, and the links contained within, may now be obsolete, inaccurate or wildly out of context, so please bear that in mind :)
Tags: dropbox / eatstatic /