Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I setup Ubuntu 11.04 desktop 32 bit on a VirtualBox VM with a shared folder to the host. The shared folder is

/media/sf_Dev/

I want to change Apache2 to point the DocumentRoot to that folder, so I edited /etc/apache2/sites-available/default to replace the existing two paths in that file to /media/sf_Dev/ instead of /var/www and it won't show index.html.

When I look at /var with ls -l I see

drwxr-xr-x  2 root root ... www

and when I ls -l /media/ I see

drwxrwx---  1 root vboxsf ... sf_Dev

and Apache doesn't seem to see the index.html I put in that directory (cp /var/www/index.html /media/sf_Dev/ iirc)

I also tried editing envvars to make the group be vboxsf but I think I did that part wrong.

export APACHE_RUN_GROUP=www-data

to

export APACHE_RUN_GROUP=vboxsf

What am I doing wrong, what do I need to do to get Apache2 to serve files from that directory? (technically I want to serve files for apache from /media/sf_Dev/apache/www but I figure one step at a time, so if that helps you short-circuit things, so be it)

share|improve this question
up vote 14 down vote accepted

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.

share|improve this answer
    
But is the apache app running under the username apache? I thought that changed >.> – jcolebrand Sep 16 '11 at 21:42
    
You're correct, I mixed the apache user for fedora and ubuntu. edited :) – Fuu Sep 16 '11 at 23:23
    
Saved me a bunch of time fiddling around with manual mounting.. thanks! – xorinzor Jul 7 '13 at 15:57
    
This solution fixed it for me on Ubuntu 15. Many thanks! – Ian Lewis Nov 4 '15 at 12:53

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.)

share|improve this answer
1  
Ahhh, but when I do that it doesn't make the changes I need. Something about the vboxfs doesn't let those changes get made (ie: like NFTS) ... oooh, which may be the problem, the files are originally hosted on NTFS (since it's a windows host) so I don't think I can do that. ~~ I had forgotten to look at the errorlog before asking. I shall check that this evening. However, assume it's a permissions error. – jcolebrand Sep 14 '11 at 15:48
    
@jcolebrand Rule #1 of troubleshooting: is it plugged in? Nevermind that I'm thinking about the long term usefulness of the answer and that I know you as a DB and .NET guy. :P – George Marian Sep 14 '11 at 21:14
    
@jcolebrand So, silly question: Did you restart apache? sudo apache2ctl restart – George Marian Sep 14 '11 at 21:16
    
hahahahaha, this is why I need help, I'm a db and .net guy ;) ... yeah, I actually dropped into sudo su once it started being a wench so I could go into all the directories and see what was "broken" ... I'm gonna do what Josh suggested later with the PHP file. – jcolebrand Sep 14 '11 at 21:16
1  
It is possible that vboxsf does not support setting permissions for the root folder of file system and it may provide mode, uid and gid mount options to set file permissions globally. – billc.cn Sep 17 '11 at 1:58

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)

share|improve this answer
    
I had forgotten to look at the errorlog before asking. I shall check that this evening. However, assume it's a permissions error. See my response to George above – jcolebrand Sep 14 '11 at 15:50
    
OK. Then we should focus on getting Apache to run as GID vboxsf. Can you edit and post the relevant parts where you changed the Group? – Josh Sep 14 '11 at 15:53
    
I edited one line in envvars, and it said group, but I'm not looking at the box right now. – jcolebrand Sep 14 '11 at 15:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .