Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I can not get any errors to display on screen on write to a log file. When check phpinfo() print out I have same value of master a local for

display_errors On 
display_startup_errors On
error_log /var/log/php.log
error_reporting E_ALL & ~E_NOTICE
log_errors On
log_errors_max_len

ls -l /var/log/php.log is -rw-rw-rw- 1 root root 0 Jun 21 07:47 /var/log/php.log for /var and /varlog drwxrwxrwx 23 root root 4096 Jun 2 11:13 var

when there is an error in the code the page the browsers shows nothing and browser says there is no source for the page. Any suggestions of where else to look or change to errors to appear somewhere (anywhere would be good)

edit: my error script is now

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
echo "print from error.php 2 ";
error                        
//print from erroerror to cuase logging to happen.
?>

this will print on display and to log

Notice: Use of undefined constant error - assumed 'error' in /var/www/piku_dev2/error.php on line 7

but if I put garbage like #@$%$ on the error line I get nor error messages anywhere.

Edit2: The problem turned out to in the httpd.conf file. I don't know what it was yet as it was fixed y someone else.

share|improve this question
    
It's possible to use error_reporting() to change the error reporting level during run-time. But how do you know this is caused by a PHP error? And this is an unlikely scenario, but the script could be using the error suppression operator @ and just terminating the script with die before any output is printed. –  Lèse majesté Jun 21 '10 at 6:44

4 Answers 4

My issue was that not only was apache not able to write to the log files, it also wasn't able to write to the /var/log/httpd directory.

My fix?

php.ini error_log = /var/log/httpd/php-error.log

chmod 777 /var/log chmod 777 /var/log/httpd

I'm running CentOS 6 by the way. There has to be a better way than chmod'ing your log and httpd folder to 777, but this was the only way I could get it to work. You could add apache to the root group, which would be a bad idea.

share|improve this answer

In the past, I had no error logs in two cases:

  1. The user under which Apache was running had no permissions to modify php_error_log file.
  2. Error 500 occurred because of bad configuration of .htaccess, for example wrong rewrite module settings. In this situation errors are logged to Apache error_log file.
share|improve this answer

I can see a few possible solutions to your problem. These are the most common issues you'll run into:

  • In your example, you use #@$%$ to induce an error. However, PHP treats any line beginning with a hash as a comment, so this line would never be evaluated, hence it would never trigger an error condition.
  • There are 2 distinct php.ini files that you should be aware of; one for Apache and one for the PHP CLI. Make sure that the one you've edited is the one for Apache if your script is being called from a web browser. The directory that this file is found in will vary from distro to distro, but the default path is usually a slight variation of /etc/php/apache/php.ini
  • You must restart Apache after making changes to the php.ini file, or send a SIGHUP to Apache to force a re-read of the configuration file.
  • The error_reporting and log_errors configuration variables can be overwritten locally within an Apache vhost file, or even in the PHP script itself. Make sure that the default server config does not overwrite these variables locally in the Apache configuration for the vhost you're using.
  • The permissions of your /var/log/php.log file need to be writeable by Apache. It's usually safe to set the owner of this file to the Apache user on your system (the Apache user is usually either www-data or apache).
share|improve this answer

It seems like the display_errors or error_reporting were overridden by something else.

It happened to me by an application that changes the error_reporting later in the bootstrap which I didn't see.

A good practice is to search for error_reporting within the application and see it is modified somewhere.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.