Im not new to php or file permissions. But i just migrated an extremely simple script to a new server I setup.
The folder which the script runs is in the document root. The permissions for the folder are set to 755.
The owner of the folder is gsta. The owner of the file is gsta.
I turned on error_reporting and am getting:
Warning: fopen(log.txt): failed to open stream: Permission denied in /var/www/html/log.php on line 13
I've tried:
chmod("log.txt", 0777)
in php and also get permission denied.
Ive done:
ps -u | grep httpd
and got:
gsta 1012 0.0 0.0 108608 808 pts/3 S+ 22:45 0:00 grep --color=auto httpd
Code:
$filename = 'log.txt';
$handle = fopen($filename,"a+");
echo "fh:" . fwrite($handle, $payload . "\n") . $handle . "<br/>";
fclose($handle);
even though it shouldnt matter PHP safemode is off
I tried setting the owner of the file to nobody (apache often runs under nobody, i also tried setting the owner to apache.
I have looked at every posting in google and its always the basic things, all of which I have tried. This was a known working script on a different server. I tried checking php.ini looking for some setting that would cause this issue. I have tried deleting the file (as it should create it in that case)
Does anyone have any ideas? Ive tried everything I can think of.
$ chmod 0777 log.txt
by actually changing permission instead of usingchmod()
?chmod
any file that isn't yours. Or, in this case, that isn't of the web server user (if you do it via php).