php - Apache 2.4 + php-fpm - AH01071 : Got error 'Primary script unknown\n' mod_proxy_balancer

标签 php mod-proxy apache2.4 mod-proxy-balancer

我正在我的 Ubuntu 14.04 中使用 php-fpm 5.5.9 配置 Apache 2.4.9。我想要的是为 php-fpm 请求创建一个平衡器,但它会抛出以下错误:

AH01071:出现错误“主脚本未知\n”

当我尝试访问我的 php 文件时。代理平衡器似乎没有获取 ProxyPassMatch 传递给它的文档根目录。我正在使用 UDS 让 apache 访问 php-fpm 套接字而不是使用网络 tcp。

如果我在没有平衡器的情况下配置它,一切正常。

作品

ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock1|fcgi://./var/www/html

不工作

ProxyPassMatch ^/(.*\.php(/.*)?)$ balancer://localhost/var/www/html
<Proxy balancer://localhost/>
    BalancerMember unix:/var/run/php5-fpm.sock1|fcgi://localhost:9001
    BalancerMember unix:/var/run/php5-fpm.sock2|fcgi://localhost:9002
    BalancerMember unix:/var/run/php5-fpm.sock3|fcgi://localhost:9003
    BalancerMember unix:/var/run/php5-fpm.sock4|fcgi://localhost:9004
</Proxy>

这是平衡器的配置日志:

[Sun Jun 15 12:32:30.839726 2014] [authz_core:debug] [pid 12217:tid 140330025703168] mod_authz_core.c(828): [client 10.1.1.2:52526] AH01628: authorization result: granted (no directives)
[Sun Jun 15 12:32:30.839899 2014] [lbmethod_byrequests:debug] [pid 12217:tid 140330025703168] mod_lbmethod_byrequests.c(97): AH01207: proxy: Entering byrequests for BALANCER (balancer://localhost)
[Sun Jun 15 12:32:30.839915 2014] [lbmethod_byrequests:debug] [pid 12217:tid 140330025703168] mod_lbmethod_byrequests.c(144): AH01208: proxy: byrequests selected worker "fcgi://localhost:9001" : busy 0 : lbstatus -3
[Sun Jun 15 12:32:30.839929 2014] [proxy_balancer:debug] [pid 12217:tid 140330025703168] mod_proxy_balancer.c(616): [client 10.1.1.2:52526] AH01172: balancer://localhost: worker (fcgi://localhost:9001) rewritten to fcgi://localhost:9001/var/www/html/info.php
[Sun Jun 15 12:32:30.839942 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(1761): AH00924: worker unix:/var/run/php5-fpm.sock1|fcgi://localhost:9001 shared already initialized
[Sun Jun 15 12:32:30.839958 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(1808): AH00927: initializing worker unix:/var/run/php5-fpm.sock1|fcgi://localhost:9001 local
[Sun Jun 15 12:32:30.840004 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(1843): AH00930: initialized pool in child 12217 for (localhost) min=0 max=25 smax=25
[Sun Jun 15 12:32:30.840018 2014] [proxy:debug] [pid 12217:tid 140330025703168] mod_proxy.c(1138): [client 10.1.1.2:52526] AH01143: Running scheme balancer handler (attempt 0)
[Sun Jun 15 12:32:30.840039 2014] [proxy_fcgi:debug] [pid 12217:tid 140330025703168] mod_proxy_fcgi.c(768): [client 10.1.1.2:52526] AH01076: url: fcgi://localhost:9001/var/www/html/info.php proxyname: (null) proxyport: 0
[Sun Jun 15 12:32:30.840058 2014] [proxy_fcgi:debug] [pid 12217:tid 140330025703168] mod_proxy_fcgi.c(775): [client 10.1.1.2:52526] AH01078: serving URL fcgi://localhost:9001/var/www/html/info.php
[Sun Jun 15 12:32:30.840090 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2094): AH00942: FCGI: has acquired connection for (localhost)
[Sun Jun 15 12:32:30.840102 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2108): AH02545: FCGI: has determined UDS as /var/run/php5-fpm.sock1
[Sun Jun 15 12:32:30.840115 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2169): [client 10.1.1.2:52526] AH00944: connecting fcgi://localhost:9001/var/www/html/info.php to localhost:9001
[Sun Jun 15 12:32:30.840134 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2304): [client 10.1.1.2:52526] AH00947: connected /var/www/html/info.php to localhost:9001
[Sun Jun 15 12:32:30.840272 2014] [authz_core:debug] [pid 12217:tid 140330025703168] mod_authz_core.c(828): [client 10.1.1.2:52526] AH01628: authorization result: granted (no directives)
[Sun Jun 15 12:32:30.842988 2014] [proxy_fcgi:error] [pid 12217:tid 140330025703168] [client 10.1.1.2:52526] AH01071: Got error 'Primary script unknown\n'
[Sun Jun 15 12:32:30.843095 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2132): AH00943: FCGI: has released connection for (localhost)
[Sun Jun 15 12:32:30.843134 2014] [proxy_balancer:debug] [pid 12217:tid 140330025703168] mod_proxy_balancer.c(670): [client 10.1.1.2:52526] AH01176: proxy_balancer_post_request for (balancer://localhost)
[Sun Jun 15 12:32:30.978315 2014] [authz_core:debug] [pid 12217:tid 140330017310464] mod_authz_core.c(802): [client 10.1.1.2:52526] AH01626: authorization result of Require all granted: granted
[Sun Jun 15 12:32:30.978346 2014] [authz_core:debug] [pid 12217:tid 140330017310464] mod_authz_core.c(802): [client 10.1.1.2:52526] AH01626: authorization result of <RequireAny>: granted
[Sun Jun 15 12:32:30.978387 2014] [core:info] [pid 12217:tid 140330017310464] [client 10.1.1.2:52526] AH00128: File does not exist: /var/www/html/favicon.ico

最佳答案

tcpdump 在这种情况下会很有帮助。

tcpdump port 9001 -A | strings

它会告诉你 apache 试图找到你的主文件的位置

关于php - Apache 2.4 + php-fpm - AH01071 : Got error 'Primary script unknown\n' mod_proxy_balancer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24229838/

相关文章:

php - Laravel 419 页面在生产服务器上已过期。 [框架: Laravel | version : 7. 5.2]

php - 使用 MYSQL 在同一部电影中插入多个 Actor

javascript - 如果文本框为空则隐藏

php - Laravel SQL 连接 - Artisan Migrate 可以工作,但应用程序无法连接

apache - Mod_Proxy 502-间歇性代理错误

Apache2 发送两个带有映射 "nph-"CGI 的 HTTP header

apache - Apache 代理问题上的 CORS(访问控制允许来源)

windows - Apache 代理 - HTTP 到 HTTPS

php - Wordpress 环境和极高的使用率 (PHP-FPM)

apache - 如何在 htaccess 中使用 IF 为某些 URL 设置状态代码