Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache access to NTFS linked folders in linux

Tags:

linux

php

apache

Using Apache2/PHP in Debian jessie, when I want to make a new subsection in document folder of Apache (/var/www) I simply create a link to an external folder where my php files exist and simply change the owner and permissions of the folder as follow and it works perfect.

ln -s /home/myname/mynewcode /var/www/test1
chown -R www-data:www-data /home/myname/mynewcode
chmod -R 755 /home/myname/mynewcode

Then I could access http://localhost/test1

But when the real folder that I want to link it, is on a NTFS partition since chown and chmod do not work, I do modify the /etc/fstab by adding the following code, therefore my NTFS partitions will mount with the required permissions and owner.

UUID=XXDDXDDXDDDXDDDD /media/myname/lable ntfs user,exec,uid=www-data,gid=www-data 0 2

ln -s /media/myname/lable/mynewcode2 /var/www/test2

But still I do get the permission error from Apache2 and I don't know what to do!!

Forbidden
You don't have permission to access /test2 on this server.
Apache/2.4.10 (Debian) Server at localhost Port 80

like image 856
AMCoded Avatar asked May 17 '15 15:05

AMCoded


1 Answers

I cannot offer a 100% working solution but I have two points which you might want to check.

First, try adding umask to the fstab line. I think this causes the permission error. umask adds correct permission to all files (644) and directories (755) when mounting. You must remount the NTFS folder!

UUID=XXDDXDDXDDDXDDDD /media/myname/lable ntfs user,exec,uid=www-data,gid=www-data,umask=022 0 2

You need to make sure, the www-data user is able to cd into the destination folder:

sudo su www-data -s bash && cd /media/myname/lable

Second, make sure "FollowSymlinks" is allowed on the specific folder, I think you have that already, but try anyways:

<Directory "/media/myname/lable/">
    Options FollowSymLinks +Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<Directory "/var/www">
    Options FollowSymLinks +Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
like image 123
Daniel W. Avatar answered Oct 01 '22 19:10

Daniel W.