- PHP runtime timeout, resulting in program error 504;
- Nginx running time timeout, resulting in program error 504;
- PHP FPM operation timed out, resulting in error 504.
1. PHP code causes program error
First, confirm the PHP version. There is one called safe under PHP 5.4_ Mode safe mode. Once enabled, some functions will fail, such as set, which solves the PHP runtime limit_ time_ Limit and Max in php.ini_ execution_ Time if you open the first mock exam mode, please turn off PHP after reboot.
PHP’s default security mode is off, so if you haven’t turned on security mode, you just need to modify Max in php.ini_ execution_ Time option, or use set in the code_ time_ Limit can solve the 504 error caused by PHP timeout.
If the PHP code still reports 504 error after processing, we can find out from ngxin to see if it is the error caused by nginx access timeout.
proxy_connect_timeout 1000; proxy_send_timeout 1000; proxy_read_timeout 1000; send_timeout 1000;
Add the above code to the nginx configuration item. It will take effect after restarting nginx. Try again to solve the request timeout problem.
If changing the above content still fails to solve the error of 504, it is likely that the fastcgi request timeout caused the program access timeout. At this time, just add the following contents to the relevant configuration of ngxin fastcgi to solve the problem of request timeout.
fastcgi_connect_timeout 1000; fastcgi_send_timeout 1000; fastcgi_read_timeout 1000;
Summary: request timeout may be caused by many reasons. According to the specific situation, the code will never cheat.
This work adoptsCC agreement, reprint must indicate the author and the link to this article