views:

47

answers:

1

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.

+2  A: 

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

Lucas Jones
he can also set 777 to individual files and access them without changing groups etc.
dusoft
If by *access* you mean *read*, 644 is enough -- no need to allow Apache to write to those files. Also make sure that all directories about the file have at least world execute permissions (711).
Wim
Both good points - thanks for raising them.
Lucas Jones