Redmine 在 Apache 中无法正常工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/996364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Redmine doesn't work properly in Apache
提问by Zr40
I'm trying to get Redmine (a Ruby on Rails app) working. It works fine when started with ruby script/server webrick -e production, however, I'm having trouble getting it working in Apache with Passenger.
我正在尝试让 Redmine(一个 Ruby on Rails 应用程序)工作。开始时它工作正常ruby script/server webrick -e production,但是,我无法在 Apache 中使用Passenger 使用它。
Accessing http://example.com/redminereturns the Redmine home page, but clicking any link (or even adding a /to the URL) results in a 404. According to the Rails log, a RoutingErroroccurs. For example, when opening the projects page: ActionController::RoutingError (No route matches "/projects.html" with {:method=>:get})
访问http://example.com/redmine返回 Redmine 主页,但单击任何链接(甚至/在 URL 中添加)都会导致 404。根据 Rails 日志,RoutingError发生了。例如,打开项目页面时:ActionController::RoutingError (No route matches "/projects.html" with {:method=>:get})
The Redmine directory is /var/www/localhost/htapps/redmine. I followed the documentation at http://www.modrails.org/documentation/Users%20guide.html#_deploying_a_ruby_on_rails_application(section 3.2), so there's a symlink at /var/www/localhost/htdocs/redminepointing to ../htapps/redmine/public, and the Apache configuration contains DocumentRoot /var/www/localhost/htdocsand RailsBaseURI /redmine.
Redmine 目录是/var/www/localhost/htapps/redmine. 我按照http://www.modrails.org/documentation/Users%20guide.html#_deploying_a_ruby_on_rails_application(第 3.2 节)上的文档进行操作,因此在/var/www/localhost/htdocs/redmine指向处有一个符号链接../htapps/redmine/public,并且 Apache 配置包含DocumentRoot /var/www/localhost/htdocs和RailsBaseURI /redmine。
What is causing it to raise these RoutingErrors?
是什么导致它引发这些 RoutingErrors?
采纳答案by Zr40
It looks like this issue was actually caused by the default .htaccess included with Redmine.
看起来这个问题实际上是由 Redmine 中包含的默认 .htaccess 引起的。
Redmine's .htaccessrewrites every request to end with .html. Redmine's routes expect .html-less requests.
Redmine 将.htaccess每个请求都重写为以 .html 结尾。Redmine 的路由需要 .html-less 请求。
Setting RewriteEngineto Offsolved the issue for me.
设置RewriteEngine来Off解决这个问题对我来说。
回答by PAT
If not deploying to a Sub-URIanddeploying using passenger, addingthe rule RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]to your public/.htaccessalso solves the issue. As that rule is IfModule-ed out in the default .htaccess.
如果不部署到子 URI并使用乘客部署,则将规则添加RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]到您的public/.htaccess也可以解决问题。由于该规则IfModule在 default 中被排除.htaccess。
Another option is to delete.htaccessif you're not using it (As an example you may be using it for additional layer authentication with AuthType Digestetc). It is not requiredwhen deploying with passenger.
如果您不使用它,另一种选择是删除.htaccess它(例如,您可能将它用于其他层身份验证AuthType Digest等)。它不需要与乘客进行部署时。
回答by iDen
Even if you will manage to run Redmine in suburi, redmine still will have issues. Some pages won't be parsed and displayed correctly, if displayed at all.
即使您将设法在 suburi 中运行 Redmine,redmine 仍然会出现问题。某些页面将无法正确解析和显示(如果根本显示)。
This issue is almost one year old and indicated for next minor release. Btw dozen minor releases came out, but it's not yet fixed. FCGI mode does not support sub-URI.
这个问题已经有将近一年的时间了,并表示会在下一个次要版本中发布。Btw 十几个小版本发布了,但还没有修复。FCGI 模式不支持 sub-URI。
回答by Corban Brook
http://ptspts.blogspot.com/2009/05/how-to-fix-railsbaseuri-sub-uri-with.html
http://ptspts.blogspot.com/2009/05/how-to-fix-railsbaseuri-sub-uri-with.html
The manual workaround (according to what is suggested on the pages above) is adding the line below to config/environments/production.rb:
手动解决方法(根据上面页面上的建议)将以下行添加到 config/environments/production.rb:
config.action_controller.relative_url_root = '/redmine'
config.action_controller.relative_url_root = '/redmine'

