You don’t have permission to access / on this server – changing default www to NTFS drive

apache-2.2linuxmintntfspermissions

i have been struggling for a couple of days about this problem.
I am trying to change the default www directory for Apache/2.4.6 (Ubuntu) web-server under LinuxMint16 and making it point to a NTFS hard disk that i share with another Windows installation.
This hard disk is mounted under /media/crash/Yari and no matter what i try, nothing works..while if i change the default www directory to something else in the same hard disk where linux is installed, everything works as expected.

Following are all the changes i have made in order to try to get things working:

The folder where i want my new www is /media/crash/Yari/www I have thus edited the /etc/apache2/apache2.conf file:

DocumentRoot /media/crash/Yari/www
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /media/crash/Yari/www>
    #Options FollowSymLinks
    Options Indexes FollowSymLinks Includes ExecCGI MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

Afterwards, as i have seen from this post
https://askubuntu.com/questions/11840/how-to-chmod-on-an-ntfs-or-fat32-partition/91054#91054
i have determined my hard disk UUID by typing

sudo blkid

and edited the file
/etc/fstab
adding this line
UUID=#my-hd-uuid# /media/crash/Yari ntfs-3g auto,users,permissions 0 0

To be sure that the apache user (in my case: www-data) had the permissions to access the files inside the new www directory i have changed the group and the owner of all the files inside the hard disk with

sudo chgrp -R www-data /media/crash/Yari
sudo chown -R www-data /media/crash/Yari
sudo chmod -R 775 /media/crash/Yari

I have checked the permissions of the new www directory and the files contained in it by doing

sudo ls -l /media/crash/Yari

and all the files and dir appear as
drwxrwxr-x 1 www-data www-data
so the previous permissions modifications where done correctly.

Unfortunately i am surely missing something as all the above have been useless!
Hope someone can help, thank you very much for any assistance.

Best Answer

In order for apache to access a directory, it must have access rights not only to that directory but to all directories above it. So you need to allow www-data read access to /media and /media/crash as well as /media/crash/Yari.

In general, I would recommend that the apache user not have write access to the directory where the web pages live. It should be enough to allow writing to the directories used for logs, run/pid files and any cache files. Of course if you have e.g. a cgi application that writes to disk, you must allow it to do so, but it would be more secure to keep any such files in a separate directory.

In any case, to solve the immediate problem, either change group ownership of /media and /media/crash to www-data, or change their permissions to 755.