且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

mod_fcgid从管道读取超时,在标头之前输出脚本的结尾,多个版本的PHP

更新时间:2023-01-12 23:40:27

我正在回答自己的问题,希望这可以节省一些人解决这个问题的时间.

I'm answering my own question hoping this will save someone hours of fighting with this problem.

为此花了很多时间,我发现罪魁祸首是在虚拟主机配置中使用 FcgidCmdOptions .如果已定义,则全局fcgid选项将被忽略!因此,除了设置FcgidIOTimeout之外,我还必须在FcgidCmdOptions中设置IOTimeout选项.

Having spent quite a lot of time on this, I've figured our that the culprit was in using FcgidCmdOptions in vhost configuration. If it's defined, global fcgid options are simply ignored! So, instead of setting FcgidIOTimeout I had to set IOTimeout option in FcgidCmdOptions.

最终配置如下:

<Virtualhost *:80>
    VirtualDocumentRoot "e:/hosts/example"
    ServerName example.local
    FcgidCmdOptions c:php/php5.5.12/php-cgi.exe \
            InitialEnv PHPRC="c:php/php5.5.12/" \
            InitialEnv PHP_FCGI_MAX_REQUESTS=1000 \
            IOTimeout 3600 \
            ConnectTimeout 3600 \
            MaxProcessLifeTime 7200 \
            IdleTimeout 3600 \
            MaxRequestsPerProcess 900
    FcgidWrapper "c:php/php5.5.12/php-cgi.exe" .php
</Virtualhost>

<Virtualhost *:81>
    VirtualDocumentRoot "e:/hosts/example"
    ServerName example.local
    FcgidCmdOptions c:php/php7.0.12/php7-cgi.exe\
            InitialEnv PHPRC="c:php/php7.0.12/" \
            InitialEnv PHP_FCGI_MAX_REQUESTS=1000 \
            IOTimeout 3600 \
            ConnectTimeout 3600 \
            MaxProcessLifeTime 7200 \
            IdleTimeout 3600 \
            MaxRequestsPerProcess 900
    FcgidWrapper "c:php/php7.0.12/php7-cgi.exe" .php
</Virtualhost>