The Computer Oracle

How do I set the Apache2 DocumentRoot to a "vboxsf" VirtualBox Shared Folder? (permissions issue?)

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind

--

Chapters
00:00 How Do I Set The Apache2 Documentroot To A &Quot;Vboxsf&Quot; Virtualbox Shared Folder? (Permissions
01:15 Answer 1 Score 3
01:51 Answer 2 Score 2
03:07 Accepted Answer Score 28
03:32 Answer 4 Score 1
05:09 Thank you

--

Full question
https://superuser.com/questions/335322/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#ubuntu #virtualbox #apachehttpserver

#avk47



ACCEPTED ANSWER

Score 28


It would probably be easiest to add the vboxsf group as a supplementary group for apache.

Ubuntu:

sudo usermod -a -G vboxsf www-data

Fedora:

sudo usermod -a -G vboxsf apache

This does it for me when I want to access auto mounted shared folders. You might also want to add your own username to the vboxsf group to access the files.




ANSWER 2

Score 3


That looks like a permissions issue. You'll need read and execute permission on /media/sf_Dev/ for "other" (the third group of permission bits, which are currently no permissions or ---).

So, you'll need to run this command (since it's Ubuntu, note the sudo):

sudo chmod 775 /media/sf_Dev/

That will add read and execute for "other" and leave full permissions for owner and group.

Also make sure that the index file actually exists in /media/sf_Dev/. (I'll assume that you forgot the sudo in the cp command and that you're not running as root.)




ANSWER 3

Score 2


You didn't say what the specific error was, only

and Apache doesn't seem to see the index.html I put in that directory

The specific error would help. You can file this in Apache's error_log, which is typically under /var/log/apache2/error.log under Ubunt, but can be configured via an ErrorLog Directive in your <VirtualHost>

Without the actual error, I assume George Marian is correct and it's a permissions error. You can check to see what group Apache is running under using:

ps -o pid,group -o atime,comm=CMD awx | grep apache

Try chainging permissions on /media/sf_Dev/ as he said.

I think you may better off handling this with an Alias directive as that will allow you to make only certain parts of your DocumentRoot point to locations outside:

Alias /info /media/sf_Dev
<Directory /media/sf_Dev >
  Order allow,deny
  Allow from all
</Directory>

EDIT: If the Apache server has mod_php (not FastCGI PHP) and is not using suexec, you can determine if Apache is running under the proper GID (group ID) with the following PHP snippit:

<?php

var_dump(posix_getegid());

Make sure that returns the same GID as vboxsf. (You can find the GID for vboxsf in /etc/groups)




ANSWER 4

Score 1


If you have configured the shared folder to be auto mounted. Then you need to first disable the same and mount the shared folder manually. If you need automount it every time you start the vm, you need to add respective entry inside your /etc/fstab. (It seems there is some issue mounting vbox shared folder through fstab. So adding below mentioned command inside /etc/rc.local worked for me to mount it on start).

Load Shared Folder with Correct User / Group

As far as I can tell, this error is due to the owner and group of the shared folder. Apache expects the files to render to belong to the group www-data. By default, however, the shared folder in VirtualBox belongs to the vboxsf user. We will add this user to the www-data group. To do so, edit the group properties on the guest:

sudo usermod -a -G vboxsf www-data

We’ll now mount the shared folder and assign it to the www-data user and group. To check out the user and group id, you can have a look at the /etc/passwd file on the guest machine (cat /etc/passwd | grep 'www-data'). On Debian based OS, both ids are usually set to the value 33. So, simply issue the following command on the guest:

mount -t vboxsf -o rw,uid=33,gid=33 website /media/sf_website

Note that website is the name of the shared folder (as illustrated in the screenshot above) and /media/sf_website is where the folder will be mounted.

Fore more details refer this link http://jimmybonney.com/articles/configure_virtualbox_shared_folder_apache_virtual_host/