Page 1 of 1
Permission Denied error with fopen()
Posted: Wed Oct 01, 2008 8:48 am
by jj0914
I wrote a php script to append content to a local text file. right now I am seeing Permission Denied error every time when I run the script.
if I move the text file under /tmp, it's fine. But it doesn't allow me to read/write/append in different folders.
the permission and user/usergroup for the folder is
drwxrwxrwx 2 apache apache
the permission and user/usergroup for the file is
-rw-rw-rw- 1 apache apache
Thanks for any suggestions and hints
Re: Permission Denied error with fopen()
Posted: Wed Oct 01, 2008 9:20 am
by jaoudestudios
If you are just testing and playing locally set the file to 0777 and it will work but not suitable for production.
But for production set to a maximum of 0775 or ideally add ftp user to group with apache and set to 0755 ( I think - its been a while).
Re: Permission Denied error with fopen()
Posted: Wed Oct 01, 2008 10:57 am
by jj0914
jaoudestudios wrote:If you are just testing and playing locally set the file to 0777 and it will work but not suitable for production.
But for production set to a maximum of 0775 or ideally add ftp user to group with apache and set to 0755 ( I think - its been a while).
I changed the file permission to be 0755 on the file, I get still Permission denied error, do you think it might be the directory permission
Re: Permission Denied error with fopen()
Posted: Wed Oct 01, 2008 12:42 pm
by jaoudestudios
change it to 0777
Re: Permission Denied error with fopen()
Posted: Wed Oct 01, 2008 1:11 pm
by jj0914
jaoudestudios wrote:change it to 0777
I changed the file name to test instead of test.txt
now I can read, but still can't write/append, I did change the file permission to 0777
Re: Permission Denied error with fopen()
Posted: Wed Oct 01, 2008 2:08 pm
by jaoudestudios
use the php functions file_get_contents and file_put_contents instead of fopen.
Out of curiosity what parameters are you sending for fopen?
Re: Permission Denied error with fopen()
Posted: Wed Oct 01, 2008 2:36 pm
by VladSun
jaoudestudios wrote:change it to 0777
drwxrwxrwx == 0777
If the owner is apache:apache a chmod 0700 should be enough ...
Hm ... the only difference between /tmp directory permission and your directory permissions is the sticky bit ...
Try chmod 1700 and tell me what happens.
Also create a php file:
, browse to it and show me the result.