Page 1 of 1
function fopen failed to open stream: Permission denied
Posted: Thu Nov 27, 2008 8:03 pm
by antoniobanjeras
helo to all php/linux experts,
im using php to modify flat files (file.txt) on Linux platform. my php files are located in /var/www/html folder. but my flat files are in /etc/somefolder.
i've chown the /etc/somefolder and all the flat files to apache.apache and chmod to 0777.
but im not able to update/modify the flat files because of the Permission denied error as above.
1. is my approach correct?
2. should i move my flat files to /var/www/html, instead of /etc/somefolder?
3. in order to modify the flat files, can we change the permission to other than 0777?
pls help
Re: function fopen failed to open stream: Permission denied
Posted: Thu Nov 27, 2008 8:59 pm
by requinix
1. Mostly correct.
If you change ownership of the files you only need to care about the first (non-zero) digit in the permission. If you don't then you use the third (non-zero) digit. chown is unnecessary.
Also, unless these files are supposed to be executable, only use 6 (eg, 0666).
Directories need to be 7 (eg, 0777). Pedantic, but security is always like that.
2. Would it make more sense to move them? Are these files
supposed to be in /etc or are you simply storing them there?
3.
Read, and see also my answer to #1.
Permission denied could mean a few things, besides file permissions themselves. Another process could have locked the file so that nothing else could access it. Back to my previous point, are these files supposed to be in /etc? It could be that they're being used: stop the process(es) using them, edit them, and restart the process(es).
Re: function fopen failed to open stream: Permission denied
Posted: Thu Nov 27, 2008 10:05 pm
by antoniobanjeras
tasairis wrote:1. Mostly correct.
If you change ownership of the files you only need to care about the first (non-zero) digit in the permission. If you don't then you use the third (non-zero) digit. chown is unnecessary.
Also, unless these files are supposed to be executable, only use 6 (eg, 0666).
Directories need to be 7 (eg, 0777). Pedantic, but security is always like that.
2. Would it make more sense to move them? Are these files
supposed to be in /etc or are you simply storing them there?
3.
Read, and see also my answer to #1.
Permission denied could mean a few things, besides file permissions themselves. Another process could have locked the file so that nothing else could access it. Back to my previous point, are these files supposed to be in /etc? It could be that they're being used: stop the process(es) using them, edit them, and restart the process(es).
hi tasairis,
thanks for the reply.
i solved the problem by creating sym links (symbolic links) using the command below:
ln /var/www/html/somefolder/filename.txt /etc/somefolder/filename.txt
the flat files (file.txt), moved to /var/www/html/somefolder. just create the link.
when u modify any file, both files will be updated.
it's the system's design to put the flat files in /etc/somefolder.
hope this reply & your reply will help anyone with the same issue.
rgds
Re: function fopen failed to open stream: Permission denied
Posted: Thu Nov 27, 2008 10:12 pm
by John Cartwright
Moved to not make multiple threads on the same subject.
Moved to Linux.