2.4.25中的mod_rewrite在php-fpm 5.6.30中触发FCGI“主脚本未知”错误

时间:2017-05-18 17:44:05

标签: php apache .htaccess mod-rewrite mod-proxy

  • Apache:2.4.25(本地)
  • PHP-FPM:5.6.30

这种情况在Apache 2.4.25下失败,但在Apache 2.4.20下运行。

测试网址:

https://server/some-app/fun

目录内容:

drwxr-xr-x 118 xx root 4012 May 18 16:12 ..
-rw-r--r--   1 xx root  155 May 18 16:15 index.php
-rwxr-xr-x   1 xx root  450 May 18 16:25 .htaccess
drwxr-xr-x   4 xx root  136 May 18 16:25 .

我希望提供index.php,并将“/ fun”作为GET参数传递。

.htaccess确定

这个版本的.htaccess提供了index.php没有问题,GET参数按预期显示“/ fun”:

RewriteEngine on

RewriteCond $1 !^(index.php)
RewriteRule ^(.*)$ index.php?/$1 [L,NS]

提供index.php,$ _GET为:

Array
(
    [/fun] => 
)

.htaccess 404

RewriteEngine on

RewriteCond $1 !^(index.php)
RewriteRule ^(.*)$ index.php/$1 [L,NS]

这一个导致404,PHP-FPM给出错误:

[proxy_fcgi:error]  [client 192.168.200.1:59812] AH01071: Got error 'Primary script unknown\n'

请注意,区别在于我从RewriteRule的替换中删除了问号。

相关的FCGI配置:

<IfModule !mod_php5.c>
    <FilesMatch \.php$>
        SetHandler "proxy:unix:///var/run/php-fpm-xyz.sock|fcgi://xyz/"
    </FilesMatch>
</IfModule>

Timeout 3000

DirectoryIndex index.php

清理日志

[ssl:info]   AH01964: Connection to child 18 established (server servername:443)
[authz_core:debug]  mod_authz_core.c(809):  AH01626: authorization result of Require all granted: granted
[authz_core:debug]  mod_authz_core.c(809):  AH01626: authorization result of <RequireAny>: granted
[perdir /data/www/some-app/] strip per-dir prefix: /data/www/some-app/fun -> fun
[perdir /data/www/some-app/] applying pattern '^(.*)$' to uri 'fun'
[perdir /data/www/some-app/] RewriteCond: input='fun' pattern='!^(index.php)' => matched
[perdir /data/www/some-app/] rewrite 'fun' -> 'index.php/fun'
[perdir /data/www/some-app/] add per-dir prefix: index.php/fun -> /data/www/some-app/index.php/fun
[perdir /data/www/some-app/] strip document_root prefix: /data/www/some-app/index.php/fun -> /some-app/index.php/fun
[perdir /data/www/some-app/] internal redirect with /some-app/index.php/fun [INTERNAL REDIRECT]
[authz_core:debug]  mod_authz_core.c(809):  AH01626: authorization result of Require all granted: granted
[authz_core:debug]  mod_authz_core.c(809):  AH01626: authorization result of <RequireAny>: granted
[perdir /data/www/some-app/] add path info postfix: /data/www/some-app/index.php -> /data/www/some-app/index.php/fun
[perdir /data/www/some-app/] strip per-dir prefix: /data/www/some-app/index.php/fun -> index.php/fun
[perdir /data/www/some-app/] applying pattern '^(.*)$' to uri 'index.php/fun'
[perdir /data/www/some-app/] RewriteCond: input='index.php/fun' pattern='!^(index.php)' => not-matched
[perdir /data/www/some-app/] pass through /data/www/some-app/index.php
[proxy:debug]  mod_proxy.c(1228):  AH01143: Running scheme unix handler (attempt 0)
[proxy_fcgi:debug]  mod_proxy_fcgi.c(913):  AH01076: url: fcgi://xyz//data/www/some-app/index.php proxyname: (null) proxyport: 0
[proxy_fcgi:debug]  mod_proxy_fcgi.c(920):  AH01078: serving URL fcgi://xyz//data/www/some-app/index.php
[proxy:debug]  proxy_util.c(2156): AH00942: FCGI: has acquired connection for (*)
[proxy:debug]  proxy_util.c(2209):  AH00944: connecting fcgi://xyz//data/www/some-app/index.php to xyz:8000
[proxy:debug]  proxy_util.c(2246):  AH02545: fcgi: has determined UDS as /var/run/php-fpm-xyz.sock
[proxy:debug]  proxy_util.c(2418):  AH00947: connected //data/www/some-app/index.php to httpd-UDS:0
[proxy:debug]  proxy_util.c(2786): AH02823: FCGI: connection established with Unix domain socket /var/run/php-fpm-xyz.sock (*)
[authz_core:debug]  mod_authz_core.c(809):  AH01626: authorization result of Require all granted: granted
[authz_core:debug]  mod_authz_core.c(809):  AH01626: authorization result of <RequireAny>: granted
[proxy_fcgi:error]   AH01071: Got error 'Primary script unknown\n'
[proxy:debug]  proxy_util.c(2171): AH00943: FCGI: has released connection for (*)

0 个答案:

没有答案