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
  • 相关阅读:
    如何使用Flannel搭建跨主机互联的容器网络
    移动端——touch事件
    Javascript 模块化指北
    vue重构--H5--canvas实现粒子时钟
    redux-saga框架使用详解及Demo教程
    前端代码编写规范
    探秘JS的异步单线程
    POJ 3714 Raid 近期对点题解
    EditText把回车键变成搜索
    Swift语言概览
  • 原文地址:https://www.cnblogs.com/thingk/p/6008860.html
Copyright © 2011-2022 走看看