Return to "Troubleshooting"

Enabling PHP Error Messages for Troubleshooting


 
The topic of this article is not supported by our customer support department, however for your convenience we are providing this material to assist you in troubleshooting potential issues related to this topic.

If your PHP pages are not functioning properly it may be useful to enable error logging so that you can debug your code.  PHP has two different methods of displaying errors; displaying errors live on the page and loggin errors to a file.


The first option, displaying live errors, is mainly used when a site is under active development; leaving the option on could expose portions of your code to viewers in the future if a problem was to occur again. To enable this function, you will need to edit the PHP configuration file; most FTP software has a function that will allow you to edit a file in the server.

To Display Live Errors

  • Create a new text file in the /etc/php.d/ directory named 99user.ini if it does not already exist.
  • Add the following line to the /etc/php.d/99user.ini file: display_errors = On
  • Save the file
  • Restart the VDS using the VDS Manager


The second method is to have the errors logged to a specific file so that the errors aren’t shown on the site. This way, only the users who have access to the files inside of your VDS have access to see the errors being generated.  All PHP errors will be logged to the Apache error log, /var/logs/httpd/error_log. 

To Log Errors to a File

  • Create a new text file in the /etc/php.d/ directory named 99user.ini if it does not already exist.
  • Add the following line to the /etc/php.d/99user.ini file: log_errors = On
  • Save the file
  • Restart the VDS using the VDS Manager

Once you have repaired any programming errors in your code, it is best to disable these options to prevent the error log from growing too quickly or to prevent web viewers from seeing error messages.