Re: Unable to fopen/fwrite
Posted: Fri Apr 22, 2011 4:09 pm
I am sorry that I seem unable to communicate even the simplest thing: the script ran on the first server for years without a problem. The second server has nothing to do with this. Nothing was moved. It was turned off then back on. The script was not changed. But clearly something is different.
Let's approach this differently: if a script can be run as the user in SSH just fine, what condition would keep the script from running from a browser? File permissions? Folder permissions? User permissions?
This is the test code:
and this is the error_log and how helpful it is
If I 777 ticker/ apache creates the file and owns it. This is not the previous behavior. As I said I've downloaded the file and uploaded a copy back over and that means as the userid and not apache. If I chown test.txt back to userid:psacln and then run the script from the browser again it is again owned by apache.
Let's approach this differently: if a script can be run as the user in SSH just fine, what condition would keep the script from running from a browser? File permissions? Folder permissions? User permissions?
This is the test code:
Code: Select all
<?php
unlink('test.txt');
$fp = fopen('test.txt', 'w');
$date = strftime('%c');
fwrite($fp, $date);
fclose($fp);
?>
Code: Select all
[client 70.84.230.166] PHP Warning: fopen(test.txt): failed to open stream: Permission denied in /var/www/vhosts/scannerbuff.net/httpdocs/ticker/test.php on line 3
[client 70.84.230.166] PHP Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/vhosts/scannerbuff.net/httpdocs/ticker/test.php on line 5
[client 70.84.230.166] PHP Warning: fclose(): supplied argument is not a valid stream resource in /var/www/vhosts/scannerbuff.net/httpdocs/ticker/test.php on line 6