Ubuntu Tips: How do you display PHP error messages?

In this post I explain how I configured the php.ini to display error messages and aid debugging.

Like me you maybe using an Ubuntu computer running Apache, MySQL and PHP to develop websites. When developing it is important to see error messages to debug your code. On occasion I have installed PHP on to Ubuntu computers and by default errors are not displayed. As this is not a production web server I updated the php.ini file to display errors. In this post I explain how I updated the php.ini to display error messages and aid debugging.

Step 1 – Open php.ini

Start by opening a new terminal window to open the php.ini file. Modifying the php.ini will allow you to tunes the setting to enable more descriptive error messages, logging, and better performance.

Enter the following command to begin editing php.ini. This will require the sudo command and therefore administrator privileges.

sudo nano /etc/php5/apache2/php.ini

Step 2 – Display Errors

Now scroll down through the file until you find the following line.

display_errors = Off

Once you have found the display_errors line replace the parameter ‘Off’ with ‘On’. Once you have made the swap save the file and then exit the editor.

display_errors = On

Step 3 – Restart Apache

Now that you have made the change to the php.ini file you need to restart the Apache web server to effect the change. To do this enter the command below into your terminal window to restart the service. Once the service has restarted you will be able to see error message in your PHP scripts instead of blank white pages.

sudo /etc/init.d/apache2 restart


  1. How To Display PHP Errors In My Script Code When Display_errors Is Disabled

This work is licenced under a Creative Commons Licence.

Copy from http://www.matthewwittering.co.uk/blog/ubuntu-tips/php-error-messages.htm

By dbglory Posted in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s