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

I have a CenOS server and i want to enable PHP error logging to a file. I have edited the php.ini file and set

error_log = /var/log/httpd/phperror.log

and also

log_errors = On

I've restarted the apache server with service httpd restart but still the /var/log/httpd/phperror.log does not get created and no errors are logged. Any idea why?

share|improve this question
    
Did you check the permissions of this file path? Is it writeable by httpd process? –  Khaled Jan 16 '12 at 13:33
    
I even put /tmp/phperror.log and the file still did not get created. –  daniels Jan 16 '12 at 22:38

2 Answers 2

You can do it by creating an empty file in dir /var/log/httpd/

#touch /var/log/httpd/phperror.log

After creating the empty file, restart the apache server and check it the log file updated with the error log.

share|improve this answer
    
...and add write permissions for apache user: chown apache. /var/log/httpd/phperror.log and chmod 750 /var/log/httpd/phperror.log –  stderr Jan 16 '12 at 14:32
    
I even put /tmp/phperror.log and the file still did not get created. –  daniels Jan 16 '12 at 22:38

It might be a better/easier idea to send the php errors to syslog. You won't have to worry about permission problems and the file should already be rotated.

error_log = syslog

Depending on your OS the errors should then go to /var/log/messages or /var/log/syslog

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.