500-php 500 no output no errors how to quickly locate the error code

Source: Internet
Author: User
Tags php error php error log

PHP 500 no output no errors how to quickly locate the error code.
No output, no error, log is normal.

I'm just re-stating it (a senior interview question):

Online code, no output, no error, log normal, LNMP SERVER 500 error How to quickly locate the error code.

Reply content:


PHP 500 no output no errors how to quickly locate the error code.
No output, no error, log is normal.

I'm just re-stating it (a senior interview question):

Online code, no output, no error, log normal, LNMP SERVER 500 error How to quickly locate the error code.

Universal Code:

register_shutdown_function(function(){ var_dump(error_get_last()); });

But the landlord still have to learn to check the error log.

The original is a face question ....

    1. Whether there is a log;

    2. Error occurs: whether the specified person occurs or all requests, is the previous or first time, the server, especially the database server load level, error can be reproduced;

    3. Have you recently published code that has changed the online infrastructure;

    4. Whether similar incidents have occurred in the past;

    5. 500 is the server internal error, you can pay attention to whether PHP-FPM is not responding, php-fpm process is normal. Second, look at the relevant code: whether to rely on external requests, whether there is a file name capitalization error problem, whether there is poor performance of the database query, whether there is a logical improper handling of the place;

Finally, after fixing the problem, improve the log information, do not tell me that there is no log, this must have a log. Also check whether the test process is complete, to avoid the next round.

Install the xdebug extension and then look at your error log.
It is highly recommended that you pinpoint the location of the error, as well as references.

According to my experience, Windows uses some integrated environment, such as memory overflow and other errors, the error log will not display error messages. (like Chrome will directly tell you HTTP 500, not error messages or white screen)

View Server error logs

Development words to modify the configuration of the service, directly display the error AH

Ini_set (' display_errors ', ' on ');

Check the PHP error log to locate the problem immediately

Strace is commonly used to track system calls and received signals when a process executes. In the Linux world, processes cannot directly access hardware devices, and when a process requires access to a hardware device (such as reading a disk file, receiving network data, and so on), it must be switched from user mode to kernel mode and access to the hardware device through system calls. Strace can trace the system calls generated by a process, including parameters, return values, and time spent executing.

pstack

command to display stack traces for each process. The Pstack command must be run by the owner or root of the corresponding process. You can use Pstack to determine where the process hangs. The only option that this command allows to use is the PID of the process to be checked.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.