Setting up Apache with Dropbox on OS X

If you have attempted to make the Apache web server that is built into OS X work with Dropbox, you have probably faced a problem where it gives you a 403 Forbidden error. On the other hand, AMPPS, for instance, has no problem using files stored in a Dropbox folder. In this article, we will show a workaround for getting Apache to work with Dropbox without changing a ton of settings or permissions. The process is the same for other UNIX distributions, but with a different user directory; usually /home/[your username].

What we will do is to make a symbolic link or symlink. You can think of this as a reference pointer from programming or a shortcut in Windows. This “shortcut” will be placed within the folder where Apache looks for our websites; /Users/[your username]/Sites in this example, but simply replace this path with wherever your Apache is looking for your files.

The idea with this approach is that we will make a virtual host for Apache that will point to our symbolic link, which will then make Apache follow it and use the files in our Dropbox folder. Do, however, note that a virtual host is not necessary as we shall see later; it is simply a matter of convenience when working on a project. You could even just change your /Users/[your username]/Sites folder to a symbolic link which will send all requests to your Dropbox folder. However, we do not recommend this particular approach; one day you may need to work on a shared project that is located outside of your own project folder. Since all requests are sent towards your own Dropbox folder, you would have to make a symbolic link within that folder which would then point to the actual project folder. As you can imagine, combining symbolic links like this can quickly turn into a maintenance nightmare. How you want to approach it depends on your setup, but in this article we will show how to make a symbolic link on a per project basis.

First open the Terminal and locate the directory in which Apache looks for your hosted files.


cd ~/Sites

The ~ refers to your user folder. Alternatively you could write cd /Users/[your username]/Sites. Now we will make the actual symbolic link. What you have to enter in the Terminal is of the format ln -s destination link_location. So, let us make a link from /Users/[your username]/Sites/project1 to /Users/[your username]/Dropbox/dev/project1:


ln -s ~/Dropbox/dev/project1 project1

The reason why we can simply write “project1” as the link location is because we are already in the directory where we want the link to be located. One can also use a full path instead. Now we will have a new file named project1 that links to ~/Dropbox/dev/project1 or /Users/[your username]/Dropbox/dev/project1. To illustrate this, type ls -al in the Terminal while being in the symbolic link’s location folder. Then find project1 on the list and you will see the below.


project1 -> /Users/[your username]/Dropbox/dev/project1

If you prefer a more graphical illustration, simply open Finder and navigate to the directory in which the symbolic link is located. Then you will see a folder with an arrow on it. If you open it, you will be taken to /Users/[your username]/Dropbox/dev/project1.

Now that the symbolic link is all set up, navigating to localhost/project1 should lead Apache to the project folder and thus render index.html, index.php or similar. To make a custom URL which you can access your project at for convenience, simply create a virtual host which points to the symbolic link – in this case /Users/[your username]/Sites/project1. This is, however, outside the scope of this article, but you can find an example of configuring a virtual host in our article about installing Zend Framework 2 on OS X Lion.

Be First to Comment

Leave a Reply

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