Why would Dropbox cause path + permission problems with apache2 virtualhost path on Ubuntu

apache-2.2dropboxvirtualhost

I'm trying to create a dev environment on my 64 bit 12.04 Ubuntu machine, and I was having the damndest time getting virtualhosts to work. I finally figured out what the problem was, but I can't understand it really.

I set the document root for my virtualhosts to be in my home directory — namely:

/home/robert/Dropbox/www/personville

When I go to www.personvillepress2.com in the browser, I get

Forbidden
You don't have permission to access / on this server.
Apache/2.2.22 (Ubuntu) Server at www.personvillepress2.com Port 80

In the logs, I see

[Sat Jun 16 09:55:25 2012] [crit] [client 127.0.0.1] (13)Permission denied: /home/robert/Dropbox/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

I move my document root directory instead to
/home/robert/www/personville

modify the virtualhost settings accordingly, reload, and then suddenly everything works! This is bad because I want to keep all my source within my Dropbox folder for backup.

My permissions for the dropbox folder seem normal enough:

robert@kundera-linux:~/Dropbox$ ls -al
total 1036
drwx------ 29 robert robert   4096 Jun 15 09:11 .
drwxr-xr-x 60 robert robert   4096 Jun 15 21:15 ..
-rw-rw-r--  1 robert robert     29 Jun 15 09:11 .dropbox
drwxrwxr-x  2 robert robert 262144 Jun 13 05:22 .dropbox.cache
drwxrwxr-x  5 robert robert   4096 Jun  9 00:00 www

No symbolic links or unusually stringent permissions. In addition, I don't see any .htaccess problems that might give any problems (and why would apache2 care about .htaccess permission problems above the Document root?)

I appreciate any ideas for how to resolve this problem in a way that lets me keep the source files within Dropbox.

The not-working virtualhost file is below:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
ServerName  personvillepress2.com
      ServerAlias www.personvillepress2.com
    # DocumentRoot /var/www
    DocumentRoot /home/robert/Dropbox/www/personville

    <Directory /home/robert/Dropbox/www/personville>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>


    ErrorLog ${APACHE_LOG_DIR}/personvillepress2error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Update: I see that others have encountered this issue before. https://stackoverflow.com/questions/9460052/how-can-i-use-a-dropbox-directory-as-a-virtual-host-document-root-in-osx

I am not really worried about security here — this is a dev box; I'm mainly worried about backup and access from other machines. I'm thinking of using git to deploy to a live site, so all I want is a way for my local data to be backed up. Can anyone suggest a solution? Thanks.

Best Answer

It looks to me like a simple permissions issue. On Ubuntu Apache runs as user www-data group www-data. As we can see from your directory listing the permissions on your ~/Dropbox directory (via .) are drwx------ or 700. Thus Apache as www-data:www-data is denied access.

chmod 755 ~/Dropbox

will probably fix the immediate problem. In general you will need to provide o:rx permissions on directories and o:r permissions on files to allow Apache to access the files.

Related Topic