zoukankan      html  css  js  c++  java
  • fastcgi模式下设置php最大执行时间

    php在执行中常见错误:
    The FastCGI process exceeded configured request timeout;
    FastCGI process exceeded configured activity timeout ;

    一、iis下

    iis下fastcgi模式执行php脚本。

    首先需要设置fastcgi的最大执行时间,在此基础上设置php脚本时间才会有效。即,假设fastcgi最大活动时间设为900s,则php用set_time_limit(max)函数,max在[0,900]有效,大于900则fastcgi断开。

    iis下fastcgi执行时间设置方法:

    在“C:/WINDOWS/system32/inetsrv/fcgiext.ini”最末php的配置内容下增加一些参数,如下:
    引用
    [Types]
    php=PHP
    [PHP]
    ExePath=C:/PHP/php-cgi.exe
    InstanceMaxRequests=10000
    EnvironmentVars=PHP_FCGI_MAX_REQUESTS:10000
    RequestTimeout=500
    ActivityTimeout=900

    注:我服务器默认为90s

    php脚本设置最大执行时间的方法:

    1.、在php.ini里面设置
    max_execution_time = 45; 
    
    2、通过PHP的ini_set 函数设置
    ini_set("max_execution_time", "45");
    
    3、通过set_time_limit 函数设置
    set_time_limit(45); 
    以上几个数字设置为0 则无限制,默认一般是30秒。偶尔有特殊情况,可以在脚本里面使用函数修改
    

      

    二、nginx下

    nano  /etc/php.ini
        max_execution_time = 900
    ...
    
    nano/etc/fpm.d/www.conf
        request_terminate_timeout = 900
    
    
    nano /etc/nginx/nginx.conf
        http {
            fastcgi_read_timeout 900; 
        }
    
    
    ...
    
    最后重启服务:
    service php-fpm reload
    service nginx reload
  • 相关阅读:
    net.sf.json Maven依赖配置
    springboot 测试 出错
    PowerDesigner 中SQL文件、数据库表反向生成PDM
    魔板问题(搜索)
    九宫重排(搜索)
    选点(树的遍历)
    【搜索】桐桐的运输方案
    细胞(搜索)
    传球游戏(dp)
    脚本_检测mysql存活状态
  • 原文地址:https://www.cnblogs.com/thingk/p/6008860.html
Copyright © 2011-2022 走看看