PHP Errors are not stored on CentOS Server

apache-2.2php.ini

I just adjusted the php.ini on my CentOS 64 Bits VPS in /etc/php.ini to log PHP errors:

cat /etc/php.ini | grep php-errors.log
error_log = /var/log/php-errors.log

I also have log_errors = on

I created the log file in /var/log/ and it is CHMOD 644. I also turned on Error reporting E_ALL

cat /etc/php.ini | grep error_reporting
; error_reporting
error_reporting = E_ALL
; Eval the expression with current error_reporting().  Set to true if you want
; error_reporting(0) around the eval().

Then I restarted the httpd daemon. When I add a file via the WordPress uploader I see it is not uploaded because of a permission issue

“cannot-open-file.png” has failed to upload due to an error
Unable to create directory wp-content/uploads/2014/05. Is its parent directory writable by the server?

, but it is not stored as an error in php-errors.php:

pwd
/var/log

ls -l | grep php
-rw-r--r-- 1 root  root        0 May  6 06:21 php-errors.log

All my other logs in /var/log/httpd are also root:root so I would assume the logging would work. And when I did adjust the file's permissions to apache:apache as suggested I still had no errors in the log file. Even adding error logging on to the .htaccess did not help.

I also checked the PHP.ini using phpinfo() . The only ini loaded is the one I adjusted in /etc/php.ini and the user and group it is using is apache – User/Group apache(48)/48 . What am I missing?

PS Could be issues with the directory for the log files as suggested here Can't configure PHP error log I am checking out more info on this.

Best Answer

From official documentation, you should change permission of /var/log/php-errors.log so the file is writable by apache user (e.g www, www-data, etc.)

#chown www:www 

error_log string

Name of the file where script errors should be logged. The file should be writable by the web server's user. If the special value syslog is used, the errors are sent to the system logger instead. On Unix, this means syslog(3) and on Windows NT it means the event log. The system logger is not supported on Windows 95. See also: syslog(). If this directive is not set, errors are sent to the SAPI error logger. For example, it is an error log in Apache or stderr in CLI. See also error_log().