Home > Backend Development > PHP Tutorial > 500 - php 500 No output, no error reported. How to quickly locate the error code?

500 - php 500 No output, no error reported. How to quickly locate the error code?

WBOY
Release: 2016-08-04 09:20:20
Original
1416 people have browsed it


php 500 No output No error reported How to quickly locate the error code?
No output, no error, logs are normal.

Let me rephrase it (an intermediate to advanced interview question):

Online code, no output, no error, logs are normal, LNMP SERVER 500 error, please tell me how to quickly locate the error code.

Reply content:


php 500 No output No error reported How to quickly locate the error code.
No output, no error, logs are normal.

Let me rephrase it (an intermediate to advanced interview question):

Online code, no output, no error, logs are normal, LNMP SERVER 500 error, please tell me how to quickly locate the error code.

Universal code:

<code>register_shutdown_function(function(){ var_dump(error_get_last()); });</code>
Copy after login

But the poster still needs to learn to check the error log.

It turned out to be an interview question. . . .

  1. Is there a log?

  2. Phenomena of the error: does it happen to the specified person or all requests, does it happen before or for the first time, the load level of the server, especially the database server, whether the error can be reproduced;

  3. Have you recently released code or changed the online infrastructure?

  4. Have similar incidents happened before?

  5. 500 is an internal server error. You can check whether php-fpm is not responding and whether the php-fpm process is normal. Secondly, take a look at the relevant code: whether it relies on external requests, whether there are spelling errors in file names, whether there are database queries with low performance, and whether there are improper logic processing;

Finally, after fixing the problem, improve the log information. Don’t tell me there is no log. There must be a log for this matter. Also check whether the test process is complete and needs to be improved to avoid going around again next time.

Install the xdebug extension and look at your error logs.
It can pinpoint the place where the error occurred, as well as citations and other information. It is highly recommended.

According to my experience, if Windows uses some integrated environments, the error log will not display error messages such as memory overflow. (Browsers like Chrome will tell you HTTP 500 directly instead of error messages or white screens)

View server error log

If you are developing, modify the configuration of the service and the error will be displayed directly

ini_set('display_errors','On');

Look at the php error log and locate the problem immediately

<code>strace -p pid 
</code>
Copy after login

strace is often used to track system calls and signals received during process execution. In the Linux world, processes cannot directly access hardware devices. When a process needs to access hardware devices (such as reading disk files, receiving network data, etc.), it must switch from user mode to kernel mode and access hardware devices through system calls. strace can trace system calls generated by a process, including parameters, return values, and execution time.

<code>pstack
</code>
Copy after login

Command to display the stack trace of each process. The pstack command must be run by the owner or root of the corresponding process. You can use pstack to determine where a process hangs. The only option allowed by this command is the PID of the process to be checked.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template