Logging and viewing PHP errors on CentOS 6.3

The default behavior on a lot of servers is to disable the logging and displaying of PHP errors. Error logging can usually be turned back on by editing the php.ini file.

First, find out which php.ini file is being used by creating a test PHP file with following content

<?php phpinfo();

Load the file up in a browser and look for the php.ini path. It should return something like /etc/php-5.5.d/php.ini

Open up that php.ini file

$ nano /etc/php-5.5.d/php.ini

Search for the following line

;error_log = php_errors.log

and replace it with this line

error_log = /var/log/httpd/php_errors.log

Save the file, and then restart apache

$ service httpd restart

Now, you can view PHP errors by running the following command

$ tail -f /var/log/httpd/php_errors.log

more CentOS posts

more PHP posts