Ubuntu Linux server - set file permissions for VirtualBox shared folder

7

2

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?

wowpatrick

Posted 2011-07-30T00:03:39.400

Reputation: 3 039

Answers

9

You can set some mounting options while mounting your the shared folder on the guest OS - here are the available options:

http://manpages.ubuntu.com/manpages/maverick/man8/mount.vboxsf.8.html

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:

dev /var/www vboxsf umask=0022,gid=33,uid=33

kerdany

Posted 2011-07-30T00:03:39.400

Reputation: 106

0

I've used VirtualBox to run LAMP stacks within my Ubuntu Host for a few years and to share directories with Macintosh or Windows OSs, without running into this problem, I've found that Samba is the easiest solution.

With Samba you can set-up a default permission mask to use on all new files or folders created in the shared folder. There is also a great Webmin plugin that makes Samba administration a breeze.

Take a look here http://www.webmin.com/samba-howto.html

Christopher

Posted 2011-07-30T00:03:39.400

Reputation: 269