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:


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

  • /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.


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

... 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.


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.

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.