php via cli effectively logs errors to /var/log/php_errors.log

But apache + php doesn't log errors.

[bla@notebook ~]$ apachectl -v
Server version: Apache/2.2.17 (Unix)
Server built:   May 19 2011 03:15:39

[bla@notebook ~]$ php -v
PHP 5.3.6 with Suhosin-Patch (cli) (built: Mar 23 2011 13:28:00) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

In php.ini I've:

display_errors = On
error_reporting = E_ALL | E_STRICT
log_errors = On
error_log = php_errors.log

httpd.conf:

ErrorLog "/var/log/httpd/error_log"

Permissions:

[bla@notebook /]$ ls -la /var/log/httpd/
-rwxrwxr-x 1 root root 133351 21.11.2011 11:18 access_log*
-rwxrwxr-x 1 root http   1307 21.11.2011 11:18 error_log*

[bla@notebook /]$ ls -la /var/log/php_errors.log 
-rwxrwxr-x 1 root http 521 14.11.2011 17:31 /var/log/php_errors.log*

As you can tell apache daemon has permissions to create into log files.

Still no errors from apache and php in /var/log/php_errors.log and /var/log/httpd/error_log

UPDATE 1. Transformed in php.ini

error_log = php_errors.log 

to full path

error_log = /var/log/php_errors.log 

Permissions were ok. But when someone can also be getting issues with it, you are able to debug setting permissions to logfile 0777 or altering file owner. Thanks @Narf

You will find usually two separate php.ini files for Apache and CLI - are you certain you are searching at the most appropriate one?

Edit:

2 more options will be able to think about:

  • some Apache directive is playing with PHP's log path (or crippling the logging options, though that's most unlikely to be) - try setting a complete road to the log file in php.ini (@Chilled Z has recommended something similar to this)
  • I observe that your PHP installation has got the Suhosin patch applied, which does several limited modifications to be able to improve security. Even though theoretically you will find sufficient permissions for any user within the http user group to create towards the logfile - there's most likely some suphp-like behavior so when your script is utilized with the web it's performed with/because the username that's set as it is owner (file who owns the script that's) - try altering it.

Check which PHP script you're being able to access, and just how Apache is set up to be able to can get on.

In certain designs (e.g. Virtual hosts, specific sites...), the mistake_log file could be set to another path/title compared to default one.

I'd then suggest to check on your Apache config files.