Re: php not reading file properly

From: Date: Wed, 20 Aug 2008 19:30:57 +0000
Subject: Re: php not reading file properly
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-278418@lists.php.net to get a copy of this message
On Wed, Aug 20, 2008 at 3:15 PM, sean greenslade <zootboysean@gmail.com>wrote: > I have this snippet of code that is supposed to read the apache access log > and display it: > <?php > $myFile = "/var/log/httpd/access_log"; > $fh = fopen($myFile, 'r'); > $theData = fread($fh, filesize($myFile)); > fclose($fh); > echo > "This weeks apache log (clears every sunday morning):". > substr($theData,0,2000); > ?> > For some reason, it displays the logs when I run the php file thru > terminal: > php -f /web/apache.php > > but not when I access it thru the web. when I browse to it, it just > displays > the static text ("This weeks apache log (clears every sunday morning):"), > not the log text. > > Very confused, > zootboy > Check permissions on the file for the user the web server is running under. I.e. if the webserver is running as user Nobody, make sure the file can be read by Nobody (you know what I mean). Steve

« previous php.general (#278418) next »