• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

PHP 'filesize' ok if ran through ssh, error in web browser

Wojtek

W as in Whisky
NLC
Hello there,

I've moved a simple script from one server to the other and something is making it not work on the new one.

It has to read the filesize of a file and display it.
If I run it through ssh with 'php script.php', the html it outputs is ok and the size is displayed. If however I access the same script.php through an internet browser, it gives me the follosing error:

Warning: filesize() [function.filesize]: stat failed for /var/www/html/asteriskmonitor/logs/Alpha.log in /var/www/html/asteriskmonitor/index.php on line 94

I've tried enabling php safe mode, openbasedir, register globals, chmodding the logs folder and it's files to 777, chowning the folder to apache:apache, but nothing seems to solve the problem.

It must be some kind of permissions issue as I mentioned earlier, root can run it fine through ssh.

Any Ideas?
 
Does it work though? That's just a warning not an error so I assume it still works. Disable all what you enabled before. Also set your error_reporting to E_ALL, that might tell you. check your logs in Apache/PHP. Check the file that is giving the warning too, Alpha.log
 
Alpha.log is the text file I'm trying to read. It is currently an empty file and I 'm expecting php to return a filesize of 0

error reporting is set to E_ALL, that's whats giving me the warning message. Otherwise I just outputs nothing.

As mentioned, it works though ssh, but not through the browser.

httpd's error log reports basically the same thing, but it also gives the IP of the machine opening the page:

[Sun May 24 04:39:06 2009] [error] [client 192.168.15.139] PHP Warning: filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for /var/www/html/asteriskmonitor/logs/Alpha.log in /var/www/html/asteriskmonitor/index.php on line 94

That's the only message in the error logs and it repeats over and over
 
Got it! ls -Z was the answer

SElinux's permissions caused the problem.
I labeled the files with httpd_sys_content_t and everything works fine now :)
 
Back
Top