Using Dropbox as an automatic and free Web Publishing solution

In addition to having moved my mail to Google Apps for your Domain I decided to take it to the next level about a month ago by using Dropbox for storing both personal as professional (viz. 3RDS-related) data in the cloud. This decision made me more mobile than ever, as I can access any file, any time, any place; This as well from my PC as from my Mac as from any other Computer that’s connected to the internet. Over the weekend I raised the bar again and started experimenting with Dropbox resulting in a method by which one can (ab?)use that very same Dropbox as an automagic Web Publishing Solution (as an alternative to SVN and other technologies).

Why use Dropbox?

It’s quite simple: Dropbox is as easy as it can be! Just install the client and drag and drop your data into your Dropbox (which is a folder located on your hard drive). From there on all syncing goes automatically, no need for one to manually invoke a commit command or anything like that. By this I always have the latest versions of all my files available on both my PC and my Mac.


Dropbox Intro Video

The great thing about Dropbox is that it supports Windows, OSX and Linux (unlike Live Mesh, which I’ve also tried) and also provides you a web interface (LM also provides you one).

However, the greatest feature (which I only discovered this weekend) is the sharing functionality: one can share parts of his Dropbox with other Dropbox users. It’s in this feature that I saw an opportunity to experiment …

The idea

It might be good to know that the current project I’m working on is from a client who has his own dedicated Windows2003 Server which I co-administer. On that server, IIS is configured to serve several sites over HTTP and one Sharepoint Portal over HTTPS. RDP access is available to me (only after establishing a VPN connection first) thus I basically have full access to the server.

Now, the idea I came up with was to create a new Dropbox account for the project (from here on named dropbox-project) and share the folder containing the project’s web files of my Dropbox (from here on named dropbox-bramus) with dropbox-project. By that dropbox-project will always have the latest files from dropbox-bramus (and vice versa)


The two Dropbox accounts, sharing 14MB in total.

By using the sharing functionality I’d also be keeping my personal files (and files from other projects) private from dropbox-project (which is the whole idea behind the sharing feature, otherwise I’d just add the client his server as a computer that connects to dropbox-bramus)


The two Dropbox accounts, folder comparison.

After having shared the files I’d install the Dropbox Client onto the client’s server and configure it to connect to dropbox-project. By this the server will always have the newest files whenever I save a new version on my computer.

The final step then would be to configure the webserver (IIS in this case) in such a manner that the Document Root of the http://www.project.com/ site points to the Dropbox Folder. By this the site will immediately be updated whenver I save a file in dropbox-bramus. As an extra, files that are uploaded via the site will appear into dropbox-project, and thus dropbox-bramus too 🙂

The procedure

Although this guide is written for Windows Server running IIS it can easily be transformed to Windows Server running Apache. Adjust/omit steps where necessary (mainly step 2)

UPDATE 2011.10.04: Joe Hewitt has instructions on how to configure/install a likewise setup on a Linux host.

It only takes three steps in order to get your Dropbox running as a Web Publishing solution. However, you won’t be able to do so if you don’t have full access to the server.

  1. Installing Dropbox on the server
  2. Sharing data between multiple Dropbox accounts
  3. Configuring the webserver
  4. Running Dropbox as a service

1. Installing Dropbox on the server

This is the most easy step there is:

  • Start a Remote Desktop connection to the server
  • On the server, download the Dropbox client from getdropbox.com and install it.
  • During the install, choose a custom location for your Dropbox if you want to (I chose to locate the dropbox on the D drive, as all webfiles of all the virtual servers are located on that drive). Note that when – for example – you choose D:\path\to\my\site\ as the Dropbox path, it will be located in D:\path\to\my\site\My Dropbox. This is something that cannot be prevented unfortunately 🙁
  • Once installed configure Dropbox to log in with the dropbox-project account

Don’t close your RDP session yet, we’ll still need to tweak some stuff on the server 😉

Note: If you are obsessed with having your data of your virtual servers tightly structured (and you are an advanced user) you can use a symlink in order to have your wwwroot/default_www outside your “My Dropbox” folder.

2. Sharing data between multiple Dropbox accounts

2.1 Send an invite from your main account to share a folder with your project account

  • Go to getdropbox.com and log in with your main Dropbox account (in my case dropbox-bramus)
  • Navigate to the folder(s) you want to share (most likely the ones with the default_www/wwwroot files in) and select “Share this” from the toolbar
  • Type in the e-mailaddress you registered dropbox-project with, in order to invite that user and finally click on the “Share Folder” button.

2.2 Accept the invite with your project account in order to access the share

  • Log out out of getdropbox.com and then log in with your Project Dropbox account (in my case dropbox-project)
  • As the “Recent Event” listing you’ll see a notification of an invite. Click on it
  • At the invite screen click on the Accept button and the folder will appear in your Dropbox

3. Configuring the webserver

CAUTION: Be sure to set the proper read/write permissions for your IIS_USR (or user running the Application Pool) on the Dropbox Folder if needed! If you do not do this it could be possible that uploads don’t work anymore or – even worse – that your entire site doesn’t work anymore.

  • If you’ve closed your RDP session with the server, re-open it
  • You’ll notice that Dropbox will tell you that several files got updated, this is the sharing in action 🙂
  • Now, open up IIS, go to the properties of your virtual server and point your IIS home directory to (a folder in) your Dropbox Folder and press OK.
  • Navigate to your site and verify that it’s working
    • If you want you can perform a little test (Make sure your RDP connection to the server is established!):

      • Open up a file on your computer (or on the server), edit it and save it.
      • Verify that both the server and your computer have the updated file
      • Verify that the file actually got updated on the URL

      Kewl, it’s working! We have just built our free Web Publishing solution … or haven’t we?

Why it it’s working now and won’t work anymore.

The Dropbox Client is a program that starts whenever your log in (check Start > Programs > Startup, you’ll see a link to Dropbox.exe there). With the RDP connection open, we are obviously logged in to the server, thus Dropbox is running. However, when closing your RDP session (viz. logging out), the Dropbox Client won’t run anymore.

You can test this yourself: close your still open RDP connection and edit a file on your local computer. Then go online to see the changes, yet you wont see them. When you then establish an RDP connection, you’ll see the files getting updated.

What now?

So, what now? Quite simple: make it so that Dropbox.exe is ran whenever the server is running. Even with no users logged in.

Hmmz, now that sounds oddly familiar:

Windows Service:

On Microsoft Windows operating systems, a Windows service is a long-running executable that performs specific functions and which is designed not to require user intervention. Windows services can be configured to start when the operating system is booted and run in the background as long as Windows is running, or they can be started manually when required. They are similar in concept to a Unix daemon.

4. Running Dropbox as a Service

Note: this guide — Abstracted from the MSFN forums — can be applied to any application. Heck, if you want you can even run notepad as a service!

In order to run Dropbox as a Service, we can use instsrv.exe and srvany.exe, both tools provided by Microsoft (published as part of the Resource Kits).

If these files are not on your server, you can download them. In my case they already were on the server, more precisely in the C:\Program Files\Windows Resource Kits\Tools\ folder.

  1. Remove the link to Dropbox.exe from the Startup folder. By this Dropbox doesn’t get run when you log in over RDP.
  2. Right click the Dropbox icon in your system tray and select Exit. By this we close the running Dropbox Client (no fear, we’re going to start it soon again).
  3. Create a new DOS command prompt and run the following command [code]path\instsrv.exe Dropbox path\srvany.exe[/code]
    where path is the path to where instrv.exe and srvany.exe are located and Dropbox is the service we are about to create. If all goes well you’ll see a result like this:

  4. Open up regedit and locate the following key (Replace Dropbox by the service name you chose in step 2):
    [code]HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dropbox[/code]

    Right click that key in the left column, select “Edit”, select “Add Key” and name it Parameters

    In the newly created Parameters key, add a new Value (again from the edit menu)with the following settings:

    • Value Name: Application
    • Data Type: REG_SZ
    • String: C:\Program Files\Dropbox\Dropbox.exe

    You should end up with a structure like this:

  5. Open up services.msc and locate the Dropbox service which is not running yet.

    Right click it and select properties.

    In the first tab, set startup type to Automatic

    In the second tab, let the service run under a specified account (most likely with administrator privileges – SEE NOTE BELOW)

    Click OK and start the service

    Do a little test by closing your RDP connection and editing a file locally. If the file also has changed on the site itself, then it’s working. If not, check your event log (Start > Run > Eventvwr)

    That’s it, we’ve successfully installed Dropbox as a Service – and along with that we’ve created our own $0 Web Publishing solution 🙂

Important Note: At the MSFN forums I read:

One problem I ran into with this method was task tray entries. Some programs won’t work if their task tray entry fails. If the software you want to run wants to put an icon in the task tray you can try enabling “Allow service to interact with the desktop” on the “Log On” tab of the Service properties. If that doesn’t work you could also try disabling the task tray entry for the program.

I first tried that and the service started indeed. However, syncing did not work. Therefore I chose to run the service as an other user, which has admin privileges (as described above). By this I’m certain that the Dropbox service will have read/write privileges on the Dropbox folder.

Help; It’s not working, I’m running IIS7/Apache, etc.

I’m quite sure you’ll find a way of getting it to run. If you find it, feel free to document it and ping this post.

Make a donation

It certainly is no obligation but it would put a smile on my face 😉

Webdevelopment , , , , , , , ,

22 Responses to Using Dropbox as an automatic and free Web Publishing solution

  1. Derek Wong says:

    While I don’t usually use IE, I am right now. And your WordPress theme doesn’t look very good (in IE7). With no comments, it looks like your comment loop isn’t getting pushed down by your post content. I’m just another dropboxer who was reading your post because it’s linked in the wiki, and I wanted to let you know (especially if this post is directed at people on the Windows platform).

  2. Bramus! says:

    Hi Derek,

    I am aware of the issue that the current WordPress theme I’m using isn’t 100% compatible with IE.

    This post indeed is target at Windows platform, yet only the server side. The client side (in my example: dropbox-bramus) can be either Windows, OSX or Linux). Above that Firefox also exists for Windows 😉

    Love your URL by the way 🙂

  3. David T says:

    Hey,

    Thanks for this. We may use this technique you’ve shown in my web development class.

    Thanks.

    Is there anywhere else where there is more dialog about this? I checked the db forum but saw nothing.

    We may also use the “let website upload to personal dropbox” technique.

    Thanks for taking the time to outline this.

    Good luck with your other projects.
    -DT

  4. Pingback: Bram.us » Calling all digital nomads: Switch your mail (and other stuff) to Google Apps … yesterday!

  5. Bruno M says:

    Very nice solution. I wonder if this would work on a shared hosting service (linux). Any ideas?

  6. Tom Guile says:

    Hi,

    Great tutorial :D, thanks for sharing :D, ask permission to save this article 🙂

    Good luck
    TG

  7. Bramus! says:

    Bruno,

    that would require for:
    – you to have shell access to the server
    – you to be able to run a daemon on that server

    How (and if) that would/could be done, I don’t know actually as y unix/linux knowledge is limited to the very basics (think “ls”, “cd”, “rm -rf”, …)

  8. Jason says:

    I like this idea alot, I just wish I could get it to work on my shared hosting account. Oh well…

  9. Ryan says:

    I’ve added some rough Linux instructions to the Dropbox wiki at http://wiki.getdropbox.com/TipsAndTricks/WebPublishingSolution — my biggest stumbling block was SELinux security settings and I think I’ve finally fixed that part.

  10. Pingback: » Crear una web con Dropbox | Informática Práctica |

  11. Pingback: Dropbox, l’arme ultime du webmaster « Delisigns

  12. Pingback: TeamDrive versus Dropbox - Online Backup und Synchronisation | Backup, Services, Sicherheit | Dr. Web Magazin

  13. Pingback: Enkel fildelning och säkerhetskopiering | Lentz-it bloggen

  14. Pingback: links for 2009-10-19 « xtra’s blog

  15. I followed these instructions, but the service would “start then immediately stop” and I would get the error pertaining to that behavior. Looked at the shortcut I had on my desktop to Dropbox and found out it is installed here for me:

    “C:\Documents and Settings\Administrator\Application Data\Dropbox\bin\Dropbox.exe” /home

    You might want to update these instructions to tell people to find out where exactly dropbox.exe is installed to! 🙂

  16. TimothyP says:

    Hi,

    Great article,
    this actually allows you to run multiple instances of dropbox on your computer as well.

    In any case. You do NOT have to change the location of the files you are hosting using IIS.

    Simply open a command prompt (cmd)
    and use ‘mktool’ to create a link/junction in your dropbox folder.

    Let’s say IIS is configured to host files in c:\inetpup\www.itcrowd.be\ and your dropbox is in c:\My Dropbox, you could run

    mklink /D /H www-itcrowd-be c:\inetpup\www.itcrowd.be\

    Easy enough right?

  17. Jeff Molby says:

    Thanks, I had forgotten all about srvany. You may want to mention that Scheduled Tasks are a less-technical (albeit less robust) alternative.

  18. Pingback: Dropbox, l'arme ultime du webmaster - Delisigns

  19. Pingback: Usi fantasiosi di Dropbox | Napolux.com

  20. Can Orhan says:

    Hello, can you please add a tutorial for Mac OSX?

  21. Pingback: Automatic website publishing with Git, GitHub-Style | Bram.us

  22. Pingback: Turn Dropbox into a Web server with Site44 | Bram.us

Leave a Reply

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