1

I'm still learning, so please bear with me.

I installed Apache, php, and mysql and have some vhosts running, used certbot to secure the domains and all is well there. I can access the domain, run scripts, etc.

I also have an internal RAID 1 array that is formatted to ext4 and is mounted to /media/mcp/Vault using the following entry in fstab:

/dev/disk/by-uuid/e80c874e-b7cf-4cd0-ab00-1b1a43b88516 /media/mcp/Vault auto nosuid,nodev,nofail,x-gvfs-show 0 0

The script in question lives in /var/www/domain.com/testwrite.php and contains nothing but the following code:

<?php

$dir    = '/media/mcp/Vault';
$files  = scandir($dir);

print_r($files);
  • /media/ is owned by root:root and has permissions of 0755.
  • /media/mcp/ is owned by root:root and has permissions of 0750
  • /media/mcp/Vault/ is owned by www-data:www-data and has permissions of 0777

Yet when I run that script, I get the following error:

Warning: scandir(/media/mcp/Vault): failed to open dir: Permission denied in /var/www/domain.com/testwrite.php on line 8

Warning: scandir(): (errno 13): Permission denied in /var/www/domain.com/testwrite.php on line 8

Line 8 is $files = scandir($dir); of course.


Edit:

I added the following to /etc/apache/apache.conf as per the linked question:

<Directory /media/mcp/Vault/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

... and restarted apache, but there was no change; I still get the same errors.

Then I changed /mcp/ to 0755 and - I think - the combination of those two changed resolved my issue.

S16
  • 165

1 Answers1

1

Try to change code under the directory It will look like

<Directory /media/mcp/Vault/> Options -Indexes AllowOverride All Require all granted </Directory>

Hope it works.