收藏文章 楼主

Nginx/Tengine服务出现504 gateway time-out解决方法

版块:网站建设   类型:普通   作者:小绿叶技术博客   查看:1286   回复:0   获赞:0   时间:2021-09-02 14:15:44

1、修改Nginx配置。

在nginx.conf中的http层加上fastcgi参数如下:



http {


    ...


    fastcgi_connect_timeout=300; #fastcgi连接超时时间,默认60秒


    fastcgi_send_timeout=300; #nginx 进程向 fastcgi 进程发送请求过程的超时时间,默认值60秒


    fastcgi_read_timeout =300  #fastcgi 进程向 nginx 进程发送输出过程的超时时间,默认值60秒


    ....


}



2、修改PHP配置

在php.ini 中找到max_execution_time参数并修改。




; Maximum execution time of each script, in seconds


;


; Note: This directive is hardcoded to 0 for the CLI SAPI


max_execution_time = 1;#限定了脚本的最大执行时间(单位是秒)



在php-fpm.conf中找到request_terminate_timeout 参数并修改



; The timeout for serving a single request after which the worker process will


; be killed. This option should be used when the 'max_execution_time' ini option


; does not stop script execution for some reason. A value of '0' means 'off'.


; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)


; Default Value: 0


;request_terminate_timeout = 0


request_terminate_timeout = 4s;#设置为 ‘0’ 表示 ‘Off’。可用单位:s(秒),m(分),h(小时)或者 d(天)。默认单位:s(秒)。默认值:0(关闭)。



修改配置后注意重启ngnix或重载配置。

提供企业建站服务,免费网防系统,提交信息登录 http://yundun.ddoss.cn 邮箱: proposal@ddoss.cn 
回复列表
默认   热门   正序   倒序

回复:Nginx/Tengine服务出现504 gateway time-out解决方法

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息