Wednesday, February 16, 2011

How to show PHP errors instead of a blank page in general or in CodeIgniter

I was having a fit because every time I broke a CodeIgniter web site, I would only get a blank page instead of a helpful PHP error. I thought the problem was with CodeIgniter, but a simple test on an external PHP page showed me that CodeIgniter was not the culprit. The culprit was my default PHP installation that came with Ubuntu LAMP.

PHP shipped with a production php.ini in my

/etc/php5/apache2

directory. It had all error displays turned off, which is a secure way to run. It also shipped with a

usr/share/doc/php5-common/examples/php.ini-development

file.

I had to go to the terminal and

'sudo gedit /etc/php5/apache2/php.ini'

and

'sudo gedit usr/share/doc/php5-common/examples/php.ini-development'

Then I saved a copy of the production version in the examples directory and put the development version in the apache2 directory as php.ini.

Finally, I had to restart apache like this

'sudo /usr/sbin/apache2ctl restart'

That's much better!

No comments: