Shared folder of VirtualBox as Apache2 www directory

1

I using VirtualBox in Windows and I have installed Kali Linux on it. I have configured NAT network so that I can connect to the Apache server in the Linux VM through Windows browser. It works fine and I can access files in /var/www folder in my VM.

I have set a shared folder that can be accessed by both Windows and Kali Linux. I want to set that folder as the www folder Apache2 server. How can I do that..?

I tried editing apache2.conf file by replacing <Directory /var/www> as <Directory /media/sf_www>. (sf_www is the shared folder). But it gives 403 error.

Then I tried replacing vboxsf:x:142: with vboxsf:x:142:www-data in /etc/group file and restart the VM. But the result was same.

So, how can I configure a shared folder as the www folder of the Apache2 server..?

Ramesh-X

Posted 2016-05-26T15:15:40.260

Reputation: 121

how do you connect the share folder - do you have a system service, use fstab or do it manually with mount command? – Marek Rost – 2016-05-26T15:46:10.507

1Problem was with the code inside the <Directory> tag. Problem solved when I changed it. I did the configuration by referring a Ubuntu tutorial and some of the things in that was not valid for Kali.. – Ramesh-X – 2016-05-27T03:31:47.813

Answers

1

No need to manually mount the folder. Tick the auto mount option in the shared folder settings. My shared folder is named as www. So the folder will be created in as media/sf_www in the VM.

Replace <Directory /var/www> ... </Directory> tag with the following code in the /etc/apache2/apache2.conf file.

<Directory /media/sf_www>
    Options Indexes
    AllowOverride None
    Order Allow,Deny
    Allow from all
    Require all granted
</Directory>

Replace DocumentRoot /var/www/html line in the file /etc/apache2/sites-available/000-default.conf with DocumentRoot /media/sf_www

Add user group in the file /ect/group.

Restart the machine. All done.

Tested in Kali Linux 2016.

Ramesh-X

Posted 2016-05-26T15:15:40.260

Reputation: 121