简体   繁体   中英

PHP error reporting: Wordpress

When I get a PHP error it comes up with a 500 internal server error page. I would like it to display the fatal error. I have spent literally days trying to get it to display the proper error. Here is what I have tried so far:

1) Editing the wp-config.php file as described here: https://help.massivedynamic.co/hc/en-us/articles/115000572108-How-to-enable-WordPress-error-reporting . I tried both the option to display the error and create logs.

2) Access Plesk and making changes according to https://support.managed.com/kb/a1937/how-to-enable-php-error-logging-in-plesk-11.aspx . This seems to change the user.ini file to read: [PHP] display_errors=on error_log="d:\\Plesk\\VHOSTS\\[MYDOMAIN]\\php.log.resources" log_errors=on . I have also tried changing the directory here manually but to no avail.

3) Adding various assortment of code in the header of the page. error_reporting(E_ALL); ini_set('display_errors', 'on'); echo "aaa"; ob_flush(); being one of many.

Can anyone suggest what more I could try?

Thank you.

a 500 is a code error, or a server system error.

you can several things you can do to debug:

  • make sure you have full error reporting on in your php.ini (or at the top of the script)
  • try a simpler bit of code to make sure its not the server throwing the error.
  • use xdebug to step through the code until you find where its failing. Then use a try/catch to try to find out what the error actually was.
  • look in the server logs if you have access to them.
  • write proper unit tests (you do write tests yes?) for the sections of code you are using. Often its easier to isolate a problem with a unit test than it is when that code is part of a much larger application.
  • use echo's and var_dumps to try to see where the code is falling over.

full error reporting. Put this at the top of your script if you dont have access to php.ini:

error_reporting(E_ALL);

You can view the error by accessing the Apache error log file for your virtual host.

If your virtual host is called example.com, then your error log file should be located at /var/www/vhosts/example.com/logs/error.log

Search your wordpress root for error_log file. Depending from your setup, it is there, or on your wamp stack log folder. Like already commented, 500 is not a PHP error but a server error, so you can't get it printed out with PHP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM