php.ini :
max_execution_time = 600
php-fpm.conf:
request_terminate_timeout = 600
nginx 进程 和 php-fpm 进程通信一般是采用套接字(ip:port)的方式。产生504错误的原因是 nginx 转发给 fastcgi 的请求没有在限制时间(默认60s)内的到响应。
需要在 nginx将php请求转发给fastCGI 的location里(或fastcgi.conf里) 配置 和 fastCGI 通信的超时时长,为了方便测试,仍设置为 10 分钟
fastcgi_connect_timeout 600;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_connect_timeout 600;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
include fastcgi_params;
}