【发布时间】:2013-02-02 12:36:41
【问题描述】:
症状
我正在尝试设置 2 个虚拟路径,一个用于我的每个 php 应用程序。一个使用 Kohana,另一个使用 Zend。两个主页都可以正常工作。然而,当我深入浏览 Kohana 应用程序时,我收到 500 Internal Server 错误。
由于我只安装了 Zend 框架应用程序,所以我只有一个默认主页。因此,我可能会在添加新页面后发现我的 Zend 应用程序也有这个问题。但是,我不希望会出现这种情况,因为我在使用 Kohana 应用程序时没有遇到主页上缺少任何 CSS(有关此症状的更多信息,请参见 Kohana 引导部分)
apache 错误日志
这是日志文件显示的内容,从下到上阅读以查看模式。
redirected from r->uri = /user/login, referer: http://app1:8080/
redirected from r->uri = /app1/index.php/user/login, referer: http://app1:8080/
redirected from r->uri = /app1/index.php/app1/index.php/user/login, referer: http://app1:8080/
redirected from r->uri = /app1/index.php/app1/index.php/app1/index.php/user/login, referer: http://app1:8080/
...continues for 7 more loops, the redirect uri growing in the same pattern each time
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., referer: http://app1:8080/
所以从日志来看,很明显是我在代码中搞砸了导致的循环。就是不知道是哪一个。
httpd.conf
这是我添加到 httpd.conf 以设置新虚拟主机的内容
<VirtualHost app1:8080>
ServerName app1
DocumentRoot /Applications/MAMP/htdocs/app1/
SetEnv APPLICATION_ENV "development"
</VirtualHost>
# this is for the zend app that seems to be working fine
<VirtualHost app2:8888>
ServerName app2
DocumentRoot /Applications/MAMP/htdocs/app2/public
SetEnv APPLICATION_ENV "development"
</VirtualHost>
等/主机
我不认为这是问题所在,但为了彻底,这里是我添加到 hosts 文件中的内容:
127.0.0.1 app1
127.0.0.1 app2
.htaccess
我也不认为问题出在我的.htaccess 上,因为我可以将整个内容注释掉,但仍然会收到此错误,但无论如何,您可以看到我已经添加的内容以尝试修复它:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)/ - [F,L]
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php [PT]
RewriteLogLevel 3
LogLevel debug
Kohana 引导程序
最后但同样重要的是,我对 Kohana bootstrap.php 文件所做的更改为我提供了一个工作主页。在此更改之前,我得到了一个无 CSS 的 html 页面:
Kohana::init(array(
//'base_url' => '/app1/',
'base_url' => '/',
'index_file' => false
));
【问题讨论】:
-
可能是 Kohanas 重定向?将
die();添加到您要检查的第一个控制器的开头。 -
没有变化。我将它添加到所有控制器和引导程序的开头。它阻止了主页的加载,但我仍然在每个其他页面上都收到服务器错误。
-
在 VirtualHost 配置中评论
SetEnv APPLICATION_ENV "development"。
标签: php apache zend-framework kohana virtualhost