I have a script and i d like to access to home directories of users in a Linux Environment.

Web root : /var/www/html/ And there are user directories such as : /home/john /home/david etc.

There are files in users home directories. The permissions of user homes belong to the users. eg: /home/david/file.txt user: david group: david

Is it possible to access these files with apache? I assume it s not because of the permission,

Is there a way around this ?

in other words, my php program under /var/www/html/index.php can acccess the files under /home/david/foo.txt

How can i get this done? Thanks.

Accepted Answer

The best way would be to have the users place the specific needed files into a pub directory, then chmod 777 that directory.

If you want to access arbitrary files in the home directory, you have to run Apache as root, which is a big security risk. (While you could change the permissions of the home directory, this can mess up a lot of programs, in my experience.)

Written by Lucas Jones
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki