0

In the post access resource on window'sntfs,we solve the problem ,succeded in making apache in debian access the resource on the window's ntfs filesystem,now i want to make apache in debian access the resource on the window's vfat filesystem.

The disk partition sda2 is vfat format.

sudo blkid |grep 995A
/dev/sdb2: LABEL="SHARED" UUID="5E9C-995A" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="efdeb9ab-e920-40e6-9d24-df672b8806e9"

I write a config in /etc/fstab to mount it automatically.

UUID=5E9C-995A  /media/debian/SHARED vfat auto ,sync,umask=000 ,rw 0  0

Now the /dev/sda2 can be mounted automatically. My apache setting on debian :

cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
 ServerName localhost
 DocumentRoot  /media/debian/SHARED/project 
 Alias  /project  "/media/debian/SHARED/project/build/html"
 <Directory /media/debian/SHARED/project>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
 </Directory>
</VirtualHost>

Set permission for /media/debian/SHARED/project.

sudo chmod -R 644 /media/debian/SHARED/project

Restart my apache:

sudo systemctl restart apache2

To input 127.0.0. and 127.0.0.1/project in firefox.

Forbidden    
You don't have permission to access this resource.
Apache/2.4.25 (Debian) Server at 127.0.0.1 Port 80

To check the log :

sudo cat /var/log/apache2/error.log

[Wed Aug 12 17:11:58.727479 2020] [core:error] [pid 3149] (13)Permission denied: [client 127.0.0.1:56434] AH00035: access to / denied (filesystem path '/media/debian/SHARED') >because search permissions are missing on a component of the path     
[Wed Aug 12 16:53:37.958950 2020] [core:error] [pid 3061] (13)Permission denied: [client 127.0.0.1:56158] AH00035: access to /project/ denied (filesystem path '/media/debian/SHARED') because search permissions are missing on a component of the path

Display the ownership on /media/debian/SHARED/project

ls -al  /media/debian/SHARED/project
total 304
drwxr-xr-x 14 root root 16384 Aug 12 14:19 .
drwxr-xr-x  4 root root 16384 Jan  1  1970 ..
drwxr-xr-x  4 root root 16384 Aug 12 14:18 build

/media/debian/SHARED located on vfat disk partition,it can't be change ownership with chown.

sudo chown -R www-data.www-data /media/debian/SHARED/project
chown: changing ownership of '/media/debian/SHARED/project': Operation not permitted

How to make apache access the resource on vfat partition ,step by step solution is apreciated.

0
2

Here's an answer to the actual problem, which you already had in your former question and which was addressed and explained. You are misled into thinking the problem is one or two directories beyond the directory causing the error. The problem is right at /media/debian/.

Stay away from /media/someuser directories such as /media/debian. They receive special treatment by the system, with directories dynamically created for each user when needed. These directories are private to the user "holding the seat" and won't allow the apache process to access them by default. It's perhaps even possible that a reboot or a simple logoff/login might reset their access rights preventing again apache httpd to access them even if it could before.

Just create the mountpoint directory elsewhere. It could be inside a new directory called /srv/ or /data/ (or maybe even in /var/www/ but I wouldn't advise it).

So for example as root:

mkdir -p /srv/media/SHARED

Then alter all your apache settings and /etc/fstab to point to /srv/media/SHARED instead of /media/debian/SHARED.

As there won't be conflicts with the tools dynamically handling the user rights as is the case in /media/debian, apache httpd's user www-data won't have permission problems to reach /srv/media/SHARED.

If that was the previous intended goal, the user debian's GUI might not display directly this directory as it's not in the reserved directory for this user. Just add a symlink or any other Desktop method to point to /srv/media or /srv/media/SHARED.


There might still be problems due to the fact that VFAT is a very limited filesystem: the Operation not permitted is a normal and expected error on VFAT for chown and chmod and can't be corrected otherwise than by not using VFAT. httpd (perhaps depending on some options) might have special interpretation for files with execution rights. If such case arises, this would be a separate problem that would simply solved by sticking to POSIX filesystems, or at least to ntfs used with ntfs-3g with tweaks (.NTFS-3G/UserMapping) to handle access rights. Avoid VFAT or ExFAT.

5
  • 1. Hard links can't go across file systems ,it result in cross -link error. – showkey Aug 15 '20 at 13:44
  • 2. Make a soft link ,apache2 still can't access the real target because of permission. – showkey Aug 15 '20 at 13:45
  • 1
    My answer never uses hardlinks or symlinks (it talks about symlinks for an hypothetical user GUI, not for the question or for apache) – A.B Aug 15 '20 at 13:49
  • @showkey what is the relevance of any sort of link? – roaima Aug 15 '20 at 14:03
  • Just realized my answer created /srv/media but not /srv/media/SHARED that I then told to use as mointpoint, which might have initially confused OP. Answer fixed. – A.B Aug 15 '20 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.