CakePHP 2.4 Apache 2.2 и PHP-FPM

Я пытаюсь получить базовую настройку приложения CakePHP 2.4 с настройкой Apache 2.2 и PHP-FPM mod_fcgi, и я сталкиваюсь с внутренними проблемами перенаправления, которые я не могу понять.

В Apache нет ничего, кроме загруженных необходимых модулей и базовой настройки.

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.

Я испробовал почти все предложения и трюки, которые я могу найти, чтобы решить проблемы с перенаправлением Cake, но, похоже, все сводится к настройке 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

Если я добавлю следующее в app/webroot/.htaccess для отладки

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

Я вижу, что в конечном итоге он переписывает странный URL-адрес, и я получаю 404 Not Found.

Запрошенный URL-адрес /app/webroot/php5.external/app/webroot/index.php не найден на этом сервере.


person carcus88    schedule 10.02.2014    source источник


Ответы (1)


Оказывается, проблема заключалась в том, что псевдоним FastCGI был таким же, как apache DocumentRoot (в данном случае /var/www)

Это превратилось в цикл, в котором /var/www присутствовал более чем в одном месте. Исправление заключается в правильном определении настройки PHP fcgi.

Например:

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
person carcus88    schedule 10.02.2014