Ubuntu Tips: 显示php错误 How do you display PHP error messages?

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 gedit /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

Links

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

From

http://matthewwittering.com/blog/ubuntu-tips/php-error-messages.html

Leave a Reply