Ok, is there a way for the PHP user (www-data) to gain access to other parts of the server, for example, /home/username/another_folder/ ?? Thanks in Advance.
Will
EDIT: Do I just add www-data to another group?? Or something like that, or is there another way?
You can create another group and add the
www-data
(if your webserver runs underwww-data
user) to this group, then assign this group to all those files you want to be accessible.Or if you just need the read permission, and it is not an issue that other users on the system have read access to your files, then just change permissions of your files (in other places) to have the read permission for
other
. For example,775
for your directories and644
for your files.Remember that you can not serve pages in places other than your Document Root (for example /var/www), even though your webserver user has the permissions to access those files.
However if you configure "aliases" or "virtual hosts" for your web server, you can make places other that your default document root, accessible by HTTP requests.
But PHP files that are under your document root and executed by the web server, CAN read contents of files outside the document root IF the web server user has enough permissions.
You could change the group ownership (
chgrp
) of your folder to www-data (if www-data is its own group.)You could change the user ownership of that folder (
chown
) andchmod
it so that multiple users can access it. (Like farzad said)You could create a group ("me_and_web") whose only members are "username" and "www-data", and
chgrp -R me_and_web /home/username/another_folder