Hey! That worked! Turns out, the folder needs exec perms to read the files.
Thanks!

On Fri, Aug 22, 2008 at 10:28 AM, Micah Gersten <[EMAIL PROTECTED]> wrote:

> What are the permssions of /var/log and /var/log/httpd?
>
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Developer
> http://www.onshore.com
>
>
>
> sean greenslade wrote:
> > Yeah, but it wouldn't read access_log.tmp, which wasn't being written to
> at
> > the time of loading. I think the whole logs folder is restricted from php
> > access.
> >
> > On Fri, Aug 22, 2008 at 10:13 AM, Ashley Sheridan
> > <[EMAIL PROTECTED]>wrote:
> >
> >
> >>  The log file was in the process of being written to as you were trying
> to
> >> read it. It's a bit like trying to look at a quark. By doing so, you've
> >> already affected its position. Although, unlike a quark, you can create
> a
> >> copy of the log file ;)
> >>
> >>   Ash
> >> www.ashleysheridan.co.uk
> >>
> >>
> >> ---------- Forwarded message ----------
> >> From: "sean greenslade" <[EMAIL PROTECTED]>
> >> To: php-general@lists.php.net
> >> Date: Fri, 22 Aug 2008 10:04:07 -0400
> >> Subject: Re: Fwd: [PHP] php not reading file properly
> >> Yeah, I tried changing the perms, and that didn't work. I originally
> made
> >> the cron job put the temp copy in the same logs folder, but it refused
> to
> >> open that. I changed it to put the temp copy in the web folder, and it
> can
> >> read that. I think apache and/or php may have certain restrictions that
> >> keep
> >> them from accessing important system folders.
> >>
> >> On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan
> >> <[EMAIL PROTECTED]>wrote:
> >>
> >>
> >>> You can change the permissions on the file, which I believe you said
> you
> >>> did. If that didn't work, it must be because you are trying to read
> from
> >>> the file at the very same instant that Apache is writing to it logging
> >>> that you are trying to access it, if that makes sense?
> >>>
> >>> Ash
> >>> www.ashleysheridan.co.uk
> >>>
> >>>
> >>> ---------- Forwarded message ----------
> >>> From: "sean greenslade" <[EMAIL PROTECTED]>
> >>> To: php-general@lists.php.net
> >>> Date: Fri, 22 Aug 2008 02:31:47 -0400
> >>> Subject: Re: Fwd: [PHP] php not reading file properly
> >>> So I made a cron jop to copy the log to the web folder every 5 minutes.
> >>> That
> >>> worked fine. It seems that php can't read the /var/log/httpd folder
> >>>
> >> without
> >>
> >>> root perms.
> >>>
> >>> On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan
> >>> <[EMAIL PROTECTED]>wrote:
> >>>
> >>>
> >>>> Yeah, Apache is still running, but it is the access log you are trying
> >>>> to read, at the same time that you are Apache is being accessed.
> >>>> Accessing the log from the terminal will be fine while Apache is
> >>>> running, as it is unlikely it is being accessed at the very same
> >>>> instant. Are you able to access other files? Also, have you tried
> >>>> copying the file to another temporary version from within PHP an
> >>>> accessing that? If that doesn't work, try executing a Bash script that
> >>>> copies it someplace. Make sure to run the script in the background,
> and
> >>>> maybe add a sleep period to it so that it doesn't interfere with
> Apache
> >>>> accessing things.
> >>>>
> >>>> Ash
> >>>> www.ashleysheridan.co.uk
> >>>>
> >>>>
> >>>> ---------- Forwarded message ----------
> >>>> From: "sean greenslade" <[EMAIL PROTECTED]>
> >>>> To: "Micah Gersten" <[EMAIL PROTECTED]>
> >>>> Date: Wed, 20 Aug 2008 19:41:54 -0400
> >>>> Subject: Re: Fwd: [PHP] php not reading file properly
> >>>> Ashley Sheridan wrote:
> >>>>
> >>>>
> >>>>> As it's the Apache access log that you are trying to read in, are you
> >>>>>
> >>> sure
> >>>
> >>>> that Apache is     >not in the process of writing to it as you are
> >>>> attempting to read from it? That might explain   >why it seems to be
> >>>>
> >>> empty,
> >>>
> >>>> although I would have thought it would just append the data to >the
> end
> >>>>
> >>> of
> >>>
> >>>> the file, rather than rewriting the whole thing.
> >>>>
> >>>> I dunno. Like I said, I can read it thru the terminal. Apache is still
> >>>> running then.
> >>>>
> >>>> As for Micah's response, that function won't work either.
> >>>>
> >>>> On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten <[EMAIL PROTECTED]>
> >>>>
> >>> wrote:
> >>>
> >>>>> If the directory above it doesn't have execute privileges, it won't
> >>>>>
> >> be
> >>
> >>>>> able to read it either.
> >>>>> Also, why not use the PHP5 function file_get_contents()?
> >>>>>
> >>>>> Thank you,
> >>>>> Micah Gersten
> >>>>> onShore Networks
> >>>>> Internal Developer
> >>>>> http://www.onshore.com
> >>>>>
> >>>>>
> >>>>>
> >>>>> sean greenslade wrote:
> >>>>>
> >>>>>> Thanks for the advice. I changed the perms to 777 and changed the
> >>>>>>
> >>> user
> >>>
> >>>>> and
> >>>>>
> >>>>>> group to apache, but it still won't open.
> >>>>>>
> >>>>>>
> >>>>>> On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel <
> >>>>>>
> >>>>> [EMAIL PROTECTED]>wrote:
> >>>>>
> >>>>>>
> >>>>>>> Does the user your PHP instance runs as have access to the file?
> >>>>>>>
> >>>  It's
> >>>
> >>>>>>> possible that it runs under a different users depending on if
> >>>>>>>
> >> you're
> >>
> >>>>> running
> >>>>>
> >>>>>>> the script on the terminal or in a web browser.  The function
> >>>>>>>
> >> fopen
> >>
> >>>> will
> >>>>
> >>>>>>> return false if the file fails to open.  Find out if $fh is equal
> >>>>>>>
> >> to
> >>
> >>>>> false.
> >>>>>
> >>>>>>> While you're debugging, you might consider changing the display
> >>>>>>>
> >>> errors
> >>>
> >>>>>>> setting to see what warning fopen generates if the file fails to
> >>>>>>>
> >>> open.
> >>>
> >>>>>  From
> >>>>>
> >>>>>>> http://us.php.net/fopen
> >>>>>>>  Errors/Exceptions
> >>>>>>>
> >>>>>>> If the open fails, the function an error of level *E_WARNING* is
> >>>>>>> generated. You may use @<
> >>>>>>>
> >>>>> http://us.php.net/manual/en/language.operators.errorcontrol.php>to
> >>>>> suppress this warning.
> >>>>>
> >>>>>>> On Wed, Aug 20, 2008 at 12:15 PM, sean greenslade <
> >>>>>>>
> >>>>> [EMAIL PROTECTED]>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
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>
> >>>>>>
> >>>>
> >>>> --
> >>>> Feh.
> >>>>
> >>>>
> >>>>
> >>> --
> >>> Feh.
> >>>
> >>>
> >>>
> >> --
> >> Feh.
> >>
> >>
> >>
> >
> >
> >
>



-- 
Feh.

Reply via email to