Not sure what I do wrong, but I cannot get notices displaying in /var/log/php-error.log

In /etc/php5/apache2/php.ini there is error_reporting = E_ALL and I am able to get notices displayed on the page itself (e.g. for a test.php page containing $x=$y; ) ... but nothing appears in the log.

What am I missing?

Comments

vacilando’s picture

If I edit /etc/apache2/sites-available/MYSITE.dev, add something like php_value error_log /home/quickstart/websites/logs2/php.error.log, making sure that php.error.log is writable, then this particular log gets populated.

But why do I have to do that? I would expect the default PHP error log (/var/log/php-error.log) should collect PHP errors in absence of more specific error logs...?

vacilando’s picture

Component: Documentation » Image Build
Category: support » bug

All right - I have found that /var/log/php-error.log was not writable.

I issued sudo chmod 777 /var/log/php-error.log and errors started to appear there.

Could you please look into the reasons and fix as necessary for the next release?

mike stewart’s picture

Status: Active » Closed (works as designed)

I beleive something in your setup changes from the original image.

sudo chmod 777 /var/log/php-error.log

You fix, although common when searching google, is dangerous, ESPECIALLY the last 7 -- which means "world" has full read/write/execute. Typically, 740 for files is plenty -- in some cases you might need (suchs as files folder 770=folder or 760=files in the folder)

I suspect the orginial problem was your user/groups were accidentally changed. check details in the folder by using the ll command alias (lowercase LL) -- and verify user:group. To fix, you'd use something like:

sudo chmod www-data:www-data /var/log/php-error.log
syntax: sudo chmod user:group [PATH]

Edit: If someone knows I'm incorrect, and permissions on the file are wrong out-of-the-box -- please feel free to re-open this issue.

vacilando’s picture

Status: Closed (works as designed) » Needs work

I beg to disagree.

Basically the question was whether a fresh Quickstart install could write to php-error.log

Now, on a different machine and different Quickstart installation, I have just witnessed the same problem again -- no entries in that log file.

The properties were as follows:
-rw-rw-r-- 1 root root 12423 2012-04-17 16:33 php-error.log

I tried chmod 740, still no luck. Tried 766 -- and the logs started to appear.

I am pretty sure I did not chmod or chown this file or its folder before, at least not knowingly.

[BTW, notably, the properties for an Apache access log, which works, have a different group: -rw-r----- 1 root adm 334501 2012-05-07 11:50 access.log]

Sean Buscay’s picture

Hi all.

I tested the following:

sudo chown root:www-data /var/log/php-error.log

sudo chmod 660  /var/log/php-error.log

660 was the tightest I could lock it down and still get the error reports showing up. Michael Cole may have a better answer. Otherwise, fyi, the above works.

mike stewart’s picture

Status: Needs work » Fixed

Ah, that makes sense. when I suggested 760 on a file ... I musta been high. :-P It would have make it executable ... dangerous.

I think @Vacilando was suggesting the the permissions on the file is incorrect on the vanilla image. I'm not sure... and haven't had time to test. However, I did test the new image setup, and as a default it is 660.

Since we've no plans to update the old 11.04 image, and the new image will work, I'm closing this issue. Here's the fix on the 7.x-2.x branch

ll /var/log/apache2/
total 140
-rw-r----- 1 root adm 87136 May 8 14:01 access.log
-rw-rw---- 1 root adm 10186 May 8 14:49 error.log
-rw-rw-r-- 1 root root 29818 May 8 14:00 other_vhosts_access.log

vacilando’s picture

Thanks, Sean & Mike. We have a fix for now and you have confirmed that perms will be all right in Quickstart 2, so that's all right for me.

Sean Buscay’s picture

Hi Mike.

Just a note. It sounds like it all works in 2.0 so it may not be an issue.

However, for the fix, note I chowned to: root:www-data

sudo chown root:www-data /var/log/php-error.log

That allowed www-data as the group to write to the file with the 660. The second 6 being the www-data group.

I'm not sure -rw-rw---- 1 root adm 10186 May 8 14:49 error.log gives www-data access to write to the error log unless if the apache user is in the adm group.

Please know, I'm not a linux permissions expert though or anything.

mike stewart’s picture

I'm not sure -rw-rw---- 1 root adm 10186 May 8 14:49 error.log gives www-data access to write to the error log unless if the apache user is in the adm group.

The 10186 above, is the file size. so, ya, there were some errors that were written. It works

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.