gpt4 book ai didi

php - Windows 上的 Apache mod_proxy_fcgi 和 PHP-FPM (php-cgi.exe) 问题(未指定输入文件。)

转载 作者:行者123 更新时间:2023-12-02 17:39:40 39 4
gpt4 key购买 nike

以下是PHP-FPM(PHP 5.5)

php-cgi.exe -b 127.0.0.1:9000

以下是mod_proxy_fcgi (Apache 2.4)

第一种方式

<Files ~ "\.(php|phtml)$">
SetHandler "proxy:fcgi://127.0.0.1:9000/"
</Files>

第二种方式

<LocationMatch ^(.*\.(php|phtml))$>
ProxyPass fcgi://127.0.0.1:9000/$1
</LocationMatch>

第三种方法

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^([^\.]+\.(php|phtml))$ fcgi://127.0.0.1:9000/$1 [P,L]
</IfModule>

以上三种方式都会出现“No input file specified”的错误。有人知道为什么吗?我该如何解决这个问题?

最佳答案

令人费解的是,只需将结尾的 / 更改为 # 似乎就可以解决问题:

<Files ~ "\.(php|phtml)$">
SetHandler "proxy:fcgi://127.0.0.1:9000#"
</Files>

为了理解这一点,我将 Apache 设置为 LogLevel debug (为简洁起见,删除了时间戳/模块/进程详细信息):

  • 使用 / 给出:

    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
  • 使用#给出:

    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

关键的区别似乎在最后一行,其中第二个(工作)方法似乎不会将任何内容记录为传递给 PHP 进程的值。

我无法解释这一点,并且在任何地方都找不到提及它的内容。 (也许比我更勇敢的人愿意深入研究 Apache 和/或 PHP 源代码来进行调查。)

请注意,除了运行 phpinfo() 之外,我还没有对此进行测试,因此不推荐将其用于生产服务器。

<小时/>

编辑

这适用于 PHP 7.0,但对于 PHP 5.6,我仍然收到“未指定输入文件”错误。

编辑 2

并且可以使用 Apache 2.4.25,但不能使用最近发布的 2.4.26!

这似乎是 CHANGES_2.4.26 文件中明确提到的不兼容雷区:

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]

documentation已更新以反射(reflect)这一点:

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.

关于php - Windows 上的 Apache mod_proxy_fcgi 和 PHP-FPM (php-cgi.exe) 问题(未指定输入文件。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36415930/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com