setting file permissions for fopen, frwrite, etc
Posted: Mon May 31, 2010 2:40 pm
I'm having trouble figuring out how to set the file permissions for the file I want to write to from my php code. The only thing I seem to be able to make work is 777, which seems too permissive.
I don't see any "php user." There's an apache demon user called wwwrun. I made this user part of the user group, but 775 did not work. There are bits and pieces of answers here and there but they don't add up to a clear general statement that helps me.
So if my /srv/www directory is owned by me, DOCUMENT_ROOT is /srv/www/htdocs, the group is 'users', and the directory has 775 permissions, and I want to do this:
to create and write to a file, what user besides myself and wwwrun needs to be in the 'users' group? Or is this the wrong way to think about it?
Thanks.
I don't see any "php user." There's an apache demon user called wwwrun. I made this user part of the user group, but 775 did not work. There are bits and pieces of answers here and there but they don't add up to a clear general statement that helps me.
So if my /srv/www directory is owned by me, DOCUMENT_ROOT is /srv/www/htdocs, the group is 'users', and the directory has 775 permissions, and I want to do this:
Code: Select all
$file = fopen("$DOCUMENT_ROOT/../orders.txt", "a");Thanks.