3

I'm running Ubuntu 18.10 over Windows 10 using Virtualbox 5.2.22

Let me explain what I'm trying to achieve. In Windows, I have two developing environments. I'm developing using a WAMP server. I use Dropbox to sync my two development environments. Here's how: I have a directory d:\Dropbox\_www then I have both of my Apaches configured exactly the same way. In development, I use SQLite, so I have no problems with the database. I've been working this way over a year with no problems.

My only problem is that I use my home computer as one of the environments, and it has been filled up with games, other programs and such, so I thought it could be a good idea to replicate my environment over a clean VM using Linux.

I made d:\dropbox\_www a shared folder, and it mounts on /media/sf__www I have full access to it, I can use VS Code to edit files and such.

Now I configured the LAMP server, Apache 2, PHP and mySQL are working perfectly, I did a small page at /var/www/test and everything is Okay

My problem is I can't configure Apache's virtual server to point to /media/sf__www. This is what I did:

In /etc/hosts I added:

laravel.com.devel    127.0.0.1

I created a laravel.conf in /etc/apache2/sites-available with the following:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /media/sf__www/lara/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ServerName laravel.com.devel
</VirtualHost>

In the apache2.conf I have the following:

<Directory "/media/sf__www/lara/">
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Then I activated the site and restarted Apache:

sudo a2ensite laravel.conf
service apache2 reload

Now, when I go to the browser all I get is a 403:

Forbidden

You don't have permission to access / on this server.
Apache/2.4.34 (Ubuntu) Server at laravel.com.devel Port 80

Thinking that it might be related to permissions in the filesystem (I'm pretty novice in Ubuntu) I did a sudo chmod 777 lara -R to change all the permissions in the directory, but still it gives me the 403.

So, any idea on how do I have to configure Apache in order to work with a directory outside /var/www/ ?

EDIT: Partial output from ll /media/sf__www/lara is:

drwxrwx--- 1 root vboxsf   4096 oct 23 17:51 ./
drwxrwx--- 1 root vboxsf   4096 dic  8 09:58 ../
drwxrwx--- 1 root vboxsf   4096 oct 26 21:05 app/
-rwxrwx--- 1 root vboxsf   1686 oct 22 18:44 artisan*
drwxrwx--- 1 root vboxsf      0 oct 21 12:08 bootstrap/
-rwxrwx--- 1 root vboxsf   1477 oct 22 18:44 composer.json*
-rwxrwx--- 1 root vboxsf 144373 oct 22 18:48 composer.lock*

Looks like you can't chmod/chown this directory


EDIT: Output of groups

luisferfranco@luisfer-vb:/media/sf__www/lara$ groups
luisferfranco adm cdrom sudo dip plugdev lpadmin sambashare vboxsf

EDIT: Output of setfacl on the directory:

luisferfranco@luisfer-vb:/media/sf__www/lara$ sudo setfacl -d -R -m u:$USER:rwx,g:www-data:rwx,o:rx /media/sf__www/lara
[sudo] contraseña para luisferfranco: 
setfacl: /media/sf__www/lara: La operación no está soportada
setfacl: /media/sf__www/lara/app: La operación no está soportada
setfacl: /media/sf__www/lara/app/Console: La operación no está soportada
setfacl: /media/sf__www/lara/app/Exceptions: La operación no está soportada

It says "operation not supported" for each file. I'm reading in other site, this might be related to the partitions


EDIT: [SOLVED]

I want to thank George Udosen (https://askubuntu.com/users/459561/george-udosen user:459561), he was in the chat for over an hour, helping me to solve this issue. He tried lots of different things until it worked. Basically what nailed the problem was adding one user to the vboxsf group as shown:

sudo adduser www-data vboxsf

Thank you very much, you took too much time from your Christmas Day to help a complete stranger, you're a great person.

13
  • what the output of ll /media/sf__www/lara/?? Dec 25, 2018 at 15:40
  • Just to show a few lines: drwxrwx--- 1 root vboxsf 4096 oct 23 17:51 ./ drwxrwx--- 1 root vboxsf 4096 dic 8 09:58 ../ drwxrwx--- 1 root vboxsf 4096 oct 26 21:05 app/ -rwxrwx--- 1 root vboxsf 1686 oct 22 18:44 artisan* drwxrwx--- 1 root vboxsf 0 oct 21 12:08 bootstrap/ Looks like you can't change ownership or permission flags on this directory, maybe because is mounted in /media/? I can write into it, tho.
    – luisfer
    Dec 25, 2018 at 15:51
  • did you change ownership as www-data group on the directory d:\dropbox\_www ?? Dec 25, 2018 at 16:09
  • No, I don't have a www-data group, I'm not sure it is needed, the other directory under /var/www where I did my testing is owned by root:root with permissions 755
    – luisfer
    Dec 25, 2018 at 16:17
  • Pls run cat /etc/passwd | grep www-data! Dec 25, 2018 at 16:20

2 Answers 2

2

Trying to have apache access shared folder from a Windows host on an Ubuntu guest is tricky as Virtualbox mounts the shared folder with the user root and group vboxsf. To get this to work after we (OP and I) tried to remount that location with the command

 sudo mount -t vboxsf -o remount,uid=1000,gid=1000,rw __www /media/sf__www

This didn't work so a workaround was used where we added the apache user www-data to the group vboxsf with the command

 sudo adduser www-data vboxsf

and with after that apache on the guest was able to access that location.

6
  • I can't. For some reason above my understanding you can't chown/chmod the /media/sf__www directory. Maybe it is because is a shared folder coming from the host machine, being a strange restriction by VirtualBox?
    – luisfer
    Dec 25, 2018 at 16:03
  • I ran the setfacl command and I'm getting an "operation not supported" (I'm translating from spanish)
    – luisfer
    Dec 25, 2018 at 16:05
  • please run groups in the VM and let me see the output! Dec 25, 2018 at 16:09
  • Done, just edited the question
    – luisfer
    Dec 25, 2018 at 16:11
  • You are running it on /media/sf_www it should be on /media/sf_www/lara!!! Dec 25, 2018 at 16:15
0

Myself is a newbie, but I can give you a little hint to resolve this case, we usually have the directory structure which are owned by root user (default). If we want our regular user to be able to modify files in our web directories, you can change the ownership by doing this:

sudo chown -R $USER:$USER /media/sf__www/lara/

Please ensure that this Lara directory is owned by the general user if not, try the above command then restart Apache, it might work for you then later you can change the mode of the directory to 755 as usual. Let me know if it resolves your issue.

4
  • Didn't work, looks like you can't change ownership or permissions in the /media/sf_www directory or its child
    – luisfer
    Dec 25, 2018 at 15:49
  • what is the result of -> ls -al /media/sf__www/lara/ ? do you get any error when you try changing the ownership and the permissions of the directory when being root ?
    – Imrank
    Dec 25, 2018 at 16:02
  • When I ran setfacl as recommended above, I got an "operation not supported" message. The chmod/chown says nothing
    – luisfer
    Dec 25, 2018 at 16:13
  • If I do a -v on chmod, it says it changed the owner, but it actually does nothing
    – luisfer
    Dec 25, 2018 at 16:14

You must log in to answer this question.

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