CakePHP2.4Apache2.2和PHP-FPM

CakePHP2.4Apache2.2和PHP-FPM,php,mod-fastcgi,Php,Mod Fastcgi,我正在尝试使用Apache2.2和PHP-FPM mod_fcgi设置获得一个基本的CakePHP 2.4应用程序设置,我遇到了内部重定向问题,我似乎无法解决 apache只加载了所需的模块和基本设置 ServerAdmin administrator@company.com ServerName company.local ServerAlias *.company.local DocumentRoot /var/www/ # Since htis is a PHP site avoid w

我正在尝试使用Apache2.2和PHP-FPM mod_fcgi设置获得一个基本的CakePHP 2.4应用程序设置,我遇到了内部重定向问题,我似乎无法解决

apache只加载了所需的模块和基本设置

ServerAdmin administrator@company.com
ServerName company.local
ServerAlias *.company.local
DocumentRoot /var/www/

# Since htis is a PHP site avoid wasting time looking for other index files
DirectoryIndex index.php

<Directory /var/www>
    Options Indexes FollowSymLinks MultiViews +ExecCGI
    Order allow,deny
    allow from all
    AllowOverride All
</Directory>
对于默认的CakePHP2.4分支,我得到以下错误

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
我已经尝试了我能找到的解决蛋糕重定向问题的每一个建议和技巧,但它似乎归结为php fpm设置

我的重写日志如下所示

# Send all php file requests to the fcgi handler
FastCgiExternalServer /var/www/php5.external -socket /var/run/php5-fpm.sock
AddHandler php5-fcgi .php
Action php5-fcgi /usr/lib/cgi-bin/php5.external
Alias /usr/lib/cgi-bin/ /var/www/
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (2) init rewrite engine with requested uri /
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (1) pass through /
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/ -> 
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (3) [perdir /var/www/] applying pattern '^$' to uri ''
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (2) [perdir /var/www/] rewrite '' -> 'app/webroot/'
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (3) [perdir /var/www/] add per-dir prefix: app/webroot/ -> /var/www/app/webroot/
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (2) [perdir /var/www/] strip document_root prefix: /var/www/app/webroot/ -> /app/webroot/
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16e10a0/initial] (1) [perdir /var/www/] internal redirect with /app/webroot/ [INTERNAL REDIRECT]
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16dcb78/initial/redir#1] (2) init rewrite engine with requested uri /app/webroot/
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16dcb78/initial/redir#1] (1) pass through /app/webroot/
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16dcb78/initial/redir#1] (3) [perdir /var/www/app/webroot/] strip per-dir prefix: /var/www/app/webroot/ -> 
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16dcb78/initial/redir#1] (3) [perdir /var/www/app/webroot/] applying pattern '.*' to uri ''
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16dcb78/initial/redir#1] (1) [perdir /var/www/app/webroot/] pass through /var/www/app/webroot/
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b60a0/subreq] (2) init rewrite engine with requested uri /app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b60a0/subreq] (1) pass through /app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b60a0/subreq] (3) [perdir /var/www/app/webroot/] strip per-dir prefix: /var/www/app/webroot/index.php -> index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b60a0/subreq] (3) [perdir /var/www/app/webroot/] applying pattern '.*' to uri 'index.php'
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b60a0/subreq] (1) [perdir /var/www/app/webroot/] pass through /var/www/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (2) init rewrite engine with requested uri /usr/lib/cgi-bin/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (1) pass through /usr/lib/cgi-bin/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (3) [perdir /var/www/] add path info postfix: /var/www/php5.external -> /var/www/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (3) [perdir /var/www/] strip per-dir prefix: /var/www/php5.external/app/webroot/index.php -> php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (3) [perdir /var/www/] applying pattern '^$' to uri 'php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (3) [perdir /var/www/] add path info postfix: /var/www/php5.external -> /var/www/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (3) [perdir /var/www/] strip per-dir prefix: /var/www/php5.external/app/webroot/index.php -> php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (3) [perdir /var/www/] applying pattern '(.*)' to uri 'php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (2) [perdir /var/www/] rewrite 'php5.external/app/webroot/index.php' -> 'app/webroot/php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (3) [perdir /var/www/] add per-dir prefix: app/webroot/php5.external/app/webroot/index.php -> /var/www/app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (2) [perdir /var/www/] strip document_root prefix: /var/www/app/webroot/php5.external/app/webroot/index.php -> /app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16b8b88/initial/redir#2] (1) [perdir /var/www/] internal redirect with /app/webroot/php5.external/app/webroot/index.php [INTERNAL REDIRECT]
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16af770/initial/redir#3] (2) init rewrite engine with requested uri /app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16af770/initial/redir#3] (1) pass through /app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16af770/initial/redir#3] (3) [perdir /var/www/app/webroot/] add path info postfix: /var/www/app/webroot/php5.external -> /var/www/app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16af770/initial/redir#3] (3) [perdir /var/www/app/webroot/] strip per-dir prefix: /var/www/app/webroot/php5.external/app/webroot/index.php -> php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16af770/initial/redir#3] (3) [perdir /var/www/app/webroot/] applying pattern '.*' to uri 'php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:08:13 --0500] [company.local/sid#7ff2c1871658][rid#7ff2c16af770/initial/redir#3] (1) [perdir /var/www/app/webroot/] pass through /var/www/app/webroot/php5.external
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (2) init rewrite engine with requested uri /
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (1) pass through /
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/ -> 
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (3) [perdir /var/www/] applying pattern '^$' to uri ''
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (2) [perdir /var/www/] rewrite '' -> 'app/webroot/'
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (3) [perdir /var/www/] add per-dir prefix: app/webroot/ -> /var/www/app/webroot/
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (2) [perdir /var/www/] strip document_root prefix: /var/www/app/webroot/ -> /app/webroot/
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d70a0/initial] (1) [perdir /var/www/] internal redirect with /app/webroot/ [INTERNAL REDIRECT]
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d2b78/initial/redir#1] (2) init rewrite engine with requested uri /app/webroot/
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d2b78/initial/redir#1] (1) pass through /app/webroot/
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d2b78/initial/redir#1] (3) [perdir /var/www/app/webroot/] strip per-dir prefix: /var/www/app/webroot/ -> 
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d2b78/initial/redir#1] (3) [perdir /var/www/app/webroot/] applying pattern '.*' to uri ''
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1d2b78/initial/redir#1] (1) [perdir /var/www/app/webroot/] pass through /var/www/app/webroot/
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1ac0a0/subreq] (2) init rewrite engine with requested uri /app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1ac0a0/subreq] (1) pass through /app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1ac0a0/subreq] (3) [perdir /var/www/app/webroot/] strip per-dir prefix: /var/www/app/webroot/index.php -> index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1ac0a0/subreq] (3) [perdir /var/www/app/webroot/] applying pattern '.*' to uri 'index.php'
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1ac0a0/subreq] (1) [perdir /var/www/app/webroot/] pass through /var/www/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (2) init rewrite engine with requested uri /usr/lib/cgi-bin/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (1) pass through /usr/lib/cgi-bin/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (3) [perdir /var/www/] add path info postfix: /var/www/php5.external -> /var/www/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (3) [perdir /var/www/] strip per-dir prefix: /var/www/php5.external/app/webroot/index.php -> php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (3) [perdir /var/www/] applying pattern '^$' to uri 'php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (3) [perdir /var/www/] add path info postfix: /var/www/php5.external -> /var/www/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (3) [perdir /var/www/] strip per-dir prefix: /var/www/php5.external/app/webroot/index.php -> php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (3) [perdir /var/www/] applying pattern '(.*)' to uri 'php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (2) [perdir /var/www/] rewrite 'php5.external/app/webroot/index.php' -> 'app/webroot/php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (3) [perdir /var/www/] add per-dir prefix: app/webroot/php5.external/app/webroot/index.php -> /var/www/app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (2) [perdir /var/www/] strip document_root prefix: /var/www/app/webroot/php5.external/app/webroot/index.php -> /app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1aeb88/initial/redir#2] (1) [perdir /var/www/] internal redirect with /app/webroot/php5.external/app/webroot/index.php [INTERNAL REDIRECT]
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1a5770/initial/redir#3] (2) init rewrite engine with requested uri /app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1a5770/initial/redir#3] (1) pass through /app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1a5770/initial/redir#3] (3) [perdir /var/www/app/webroot/] add path info postfix: /var/www/app/webroot/php5.external -> /var/www/app/webroot/php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1a5770/initial/redir#3] (3) [perdir /var/www/app/webroot/] strip per-dir prefix: /var/www/app/webroot/php5.external/app/webroot/index.php -> php5.external/app/webroot/index.php
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1a5770/initial/redir#3] (3) [perdir /var/www/app/webroot/] applying pattern '.*' to uri 'php5.external/app/webroot/index.php'
192.168.56.1 - - [09/Feb/2014:22:09:37 --0500] [company.local/sid#7fc4fe367678][rid#7fc4fe1a5770/initial/redir#3] (1) [perdir /var/www/app/webroot/] pass through /var/www/app/webroot/php5.external
如果我将以下内容添加到app/webroot/.htaccess进行调试

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
我可以看到,它最终重写了一个时髦的URL,我得到了一个404找不到


在此服务器上找不到请求的URL/app/webroot/php5.external/app/webroot/index.php。

因此,问题在于FastCGI别名与apache DocumentRoot相同(在本例中为/var/www)

这变成了一个循环,其中/var/www出现在多个地方。修复方法是正确定义fcgi PHP设置

例如:

FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi