Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

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
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.