apachegoogle-drive-apilocalhosthttp-status-code-403document-root

Why is localhost (DocumentRoot) blocked from running on GoogleDrive, Dropbox or Tresorit?


I am attempting to relocate my DocumentRoot (i.e. localhost) to a synchronised folder (such as Google Drive, Dropbox or Tresorit), but the attempt fails with a 403 error.

On Windows machines I can configure localhost to run from D:/GoogleDrive/SitesG folder; the local site runs perfectly.

On a Mac, however, localhost won't work when running out of a cloud-based storage folder such as Google Drive, Dropbox, Tresorit, etc.

Everything is fine when localhost is at Users/myname/Sites.

However, when I reconfigure the Mac to run from Users/myname/GoogleDrive/SitesG - e.g. by editing the httpd.conf, etc, files - localhost is blocked.

Clearly the problem is to do with permissions on the parent folder (e.g. the Google Drive or Dropbox or Tresorit folder). I can see that the permissions on the various folders are as follows.

drwxr-xr-x  32 myname  staff  1024 30 Apr 02:23 Sites
drwxr-xr-x   22 myname  staff      704 30 May 21:01 SitesG
drwx------@ 61 myname  staff  1952 30 May 17:47 GoogleDrive

So my question is: On a Mac (running HighSierra), is it possible to relocate the DocumentRoot to GoogleDrive? Or is there something instrinsic to GoogleDrive that prohibits localhost from being run a Google Drive folder?

enter image description here


Solution

  • Many thanks to @DrFred for the solution above, which I'm confident would work though I have not had the chance to test it.

    Here's the solution I devised before receiving any answers. It's very similar to Dr Fred's above, in that both solve the problem with symlinks. I add mine for completeness and extra detail.

    As above, I develop on multiple devices (several Macs and Windows PCs, side by side), so my aim was to have a single localhost development folder that would synch almost instantly between different devices without the need to check files into/out of git and without running into the file permissions problems created when using Google Drive to synch code files.

    The steps I used to achieve this aim were as follows.

    1. Create a folder called ~/Users/myname/SitesNew on a Mac.

    2. Create a symlink from that folder to an identically named folder in Dropbox on the same Mac. You will then have two identical folders on the Mac:

      • ~/Users/myname/SitesNew <-- Real folder on Mac
      • ~/Users/myname/Dropbox/SitesNew <-- Symbolic folder on Mac
    3. Synchronise Dropbox on all devices (making sure to add the SitesNew folder if you are using selective synch on any device). The symlink folder will now appear as a real folder on Dropbox in the cloud and on the Windows PCs. In my case the new Windows PC folder was at:
      • D:/Dropbox/SitesNew <-- Real folder on Windows
    4. Update the Apache httpd.conf files on the Mac to recognise localhost at ~/Users/myname/SitesNew.
    5. Update the Apache httpd.conf on the Windows PC to recognise localhost at D:/Dropbox/SitesNew.

    From now on, any localhost development work (edit, add, delete) on one device will synch with the localhost on the other, even across different operating systems.

    Note 1: This solution works only with Dropbox but not with Google Drive, as Google Drive has problems with symlinks and also messes with permissions in a different way, especially on a Mac.

    Note 2: If any files have previously been saved on Google Drive (e.g. originally my Windows sites folder was at D:\GoogleDrive\SitesOld), use chmod both (a) to determine the right values for the permissions (e.g. see https://chmod-calculator.com), and (b) to convert folders and files to the right values.