2014-02-10 83 views
2

我正在尝试使用Apache 2.2和PHP-FPM mod_fcgi安装程序来获取基本的CakePHP 2.4应用程序安装程序,并且遇到了内部重定向问题,我似乎无法弄清楚。CakePHP 2.4 Apache 2.2和PHP-FPM

的阿帕奇没有什么,但加载所需的模块和基本设置

ServerAdmin [email protected] 
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> 

的PHP FastCGI进程设置是这样的

# 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/ 

使用默认的CakePHP的2.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设置

我重写日志看起来是这样的

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 

如果我以下内容添加到应用程序/ Webroot公司/的.htaccess调试

RewriteCond %{ENV:REDIRECT_STATUS} 200 
RewriteRule .* - [L] 

我可以看到,它结束了重写一个时髦的URL,我得到一个404未找到

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

回答

2

因此,原来的问题是具有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