Apache mod_proxy_fcgi and PHP-FPM (php-cgi.exe) issue (No input file specified.) on Windows

后端 未结 5 1934
别跟我提以往
别跟我提以往 2021-02-20 00:22

The following is PHP-FPM (PHP 5.5)

php-cgi.exe -b 127.0.0.1:9000

The following is mod_proxy_fcgi (Apache 2.4)

The first way

<         


        
5条回答
  •  無奈伤痛
    2021-02-20 00:30

    Inexplicably, simply changing the trailing / to a # seems to fix the problem:

    
        SetHandler "proxy:fcgi://127.0.0.1:9000#"
    
    

    In trying to understand this I set Apache to LogLevel debug (timestamp/module/process details removed for brevity):

    • Using / gives:

      mod_proxy_fcgi.c(911): [client ::1:60730] AH01076: url: fcgi://127.0.0.1:9000/E:/test/webroot/test.php proxyname: (null) proxyport: 0
      mod_proxy_fcgi.c(920): [client ::1:60730] AH01078: serving URL fcgi://127.0.0.1:9000/E:/test/webroot/test.php
      proxy_util.c(2154): AH00942: FCGI: has acquired connection for (*)
      proxy_util.c(2208): [client ::1:60730] AH00944: connecting fcgi://127.0.0.1:9000/E:/test/webroot/test.php to 127.0.0.1:9000
      proxy_util.c(2417): [client ::1:60730] AH00947: connected /E:/test/webroot/test.php to 127.0.0.1:9000
      
    • Using # gives:

      mod_proxy_fcgi.c(911): [client ::1:60738] AH01076: url: fcgi://127.0.0.1:9000#E:/test/webroot/test.php proxyname: (null) proxyport: 0
      mod_proxy_fcgi.c(920): [client ::1:60738] AH01078: serving URL fcgi://127.0.0.1:9000#E:/test/webroot/test.php
      proxy_util.c(2154): AH00942: FCGI: has acquired connection for (*)
      proxy_util.c(2208): [client ::1:60738] AH00944: connecting fcgi://127.0.0.1:9000#E:/test/webroot/test.php to 127.0.0.1:9000
      proxy_util.c(2417): [client ::1:60738] AH00947: connected  to 127.0.0.1:9000
      

    The crucial difference appears to be in the last line, where the second (working) method doesn't appear to log anything as the value passed to the PHP process.

    I'm at a loss to explain this and can't find mention of it anywhere. (Perhaps a braver soul than I would be willing to delve into the Apache and/or PHP source to investigate.)

    Note that I haven't tested this beyond running phpinfo() so wouldn't recommend it for a production server.


    Edit

    This works for PHP 7.0, but with PHP 5.6 I still get the 'No input file specified' error.

    Edit 2

    And working with Apache 2.4.25, but not the recently released 2.4.26!

    This seems to be an incompatibility minefield that is explicitly mentioned in the CHANGES_2.4.26 file:

    mod_proxy_fcgi: Return to 2.4.20-and-earlier behavior of leaving a "proxy:fcgi://" prefix in the SCRIPT_FILENAME environment variable by default. Add ProxyFCGIBackendType to allow the type of backend to be specified so these kinds of fixups can be restored without impacting FPM. PR60576 [Eric Covener, Jim Jagielski]

    The documentation has been updated to reflect this:

    One example of values that change based on the setting of this directive is SCRIPT_FILENAME. When using mod_proxy_fcgi historically, SCRIPT_FILENAME was prefixed with the string "proxy:fcgi://". This variable is what some generic FastCGI applications would read as their script input, but PHP-FPM would strip the prefix then remember it was talking to Apache. In 2.4.21 through 2.4.25, this prefix was automatically stripped by the server, breaking the ability of PHP-FPM to detect and interoperate with Apache in some scenarios.

提交回复
热议问题