2014-02-10 61 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