Setting up localhost Apache/PHP on iCloud Drive
Update: I now use vvv on Dropbox instead, it’s a much simpler setup, more time building, less time with system admin work.
Prerequisite: you have a normal localhost LAMP setup, and your
localhost/~username/ host serves the contents of
~/Sites/. If you don’t here’s the best step-by-step to get it running.
Alright, lets go:
iCloud drive is a neat place to save your localhost server contents as it backs up remotely and syncs across all devices. So work and home computer can have the same localhost files. As well iOS apps have access to it. A pretty cool way to do things.
Here’s how I got it running.
We’re going to point Apache to run off a folder in our iCloud drive, we’ll keep it named
Sites (but it’s not the same as
~/Sites/), create it in iCloud Drive, add a sub folder named
_temp and a
index.php file with whatever
phpinfo() or something therein to let you know when you’ve got things working.
Into Apache’s configuration:
sudo vi /etc/apache2/httpd.conf
DocumentRoot and change to the following lines:
While in the file, we’ll also change the permissions of Apache to our current user
Then we need to change the owners of Apache to us:
And we’ll repeat for username.conf
sudo vi /etc/apache2/users/username.conf
And now let’s hide our temp folder from Finder
My understanding of the security involved with this is making sure PHP can’t touch anything outside of your Localhost directory in iCloud drive. The risks of a localhost being compromised is low but apparently possible using malicious scrips that fire off of localhost links. To prevent this, you can run localhost off of a random port instead of
80, and always ensure you have a good htaccess firewall preventing malicious queries.