I have Ubuntu server with Apache 2, PHP, and various DBMSs running in VirtualBox on my Mac host for my web development work. To easily create/edit the files I'm working on, I mounted a directory from my Mac host via the VirtualBox shared directory feature to /var/www/
. Every file I create on my Mac host has the following permissions on the on the Server: -rw-r--r-- 1 root root 6 2011-07-30 01:27 test
.
The problem is that most PHP scripts/frameworks/etc. need write access to some files. It is extremely annoying to have to chmod every new file/directory that needs write access. Is there a way to set the correct permissions for the files/directories automatically?
Best Answer
You can set some mounting options while mounting your the shared folder on the guest OS - here are the available options:
There are many solutions to your problem:
To make the files seen as owned by your VirtualBox user's uid and gid (using the uid and gid mounting options).
To override the mode of all files/directories using dmode and fmode options.
To change the umask on your host to a less restrictive mask.
I usually prefer the first option. In your case the entry to the
/etc/fstab
file should look like this: