我在windows上有apache2.2。我正在尝试同时提供subversion(/ svn)和redmine(/ redmine)。我用这个配置运行svn很好:
<Location /svn>
DAV svn
SVNParentPath C:/svn_repository
...
</Location>
这很有效 - 我的svn用户可以点击 HTTP:// myBox上/ SVN 正好。
现在我想为rails app(RedMine)添加另一个目录:
我遵循了建议 这个问题 设置一个mongrel服务器并让apache代理客户端通过它。如果我把它作为根目录它可以正常工作 - 但是我在子目录中制作它时遇到了麻烦:
<Location /redmine>
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
有什么建议么?
这是我必须改变的:
我删除了斜杠:
<Location /redmine>
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000/
</Location>
在我的rails应用程序中:
# added to end of file C:\redmine\config\environment.rb
ActionController::AbstractRequest.relative_url_root = "/redmine"
现在它正在运作!
我对这种方法并不完全满意 - 我遇到了一些重定向问题。这是迄今为止似乎运作良好的另一种尝试。
第二种方法似乎更好。
更新:
正如评论中所述,对于在Rails 2.3.2+上运行的最新应用程序,请使用此代码:
config.action_controller.relative_url_root = '/redmine'
我把它放在新的 additional_environment.rb
文件。
这是我必须改变的:
我删除了斜杠:
<Location /redmine>
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000/
</Location>
在我的rails应用程序中:
# added to end of file C:\redmine\config\environment.rb
ActionController::AbstractRequest.relative_url_root = "/redmine"
现在它正在运作!
我对这种方法并不完全满意 - 我遇到了一些重定向问题。这是迄今为止似乎运作良好的另一种尝试。
第二种方法似乎更好。
更新:
正如评论中所述,对于在Rails 2.3.2+上运行的最新应用程序,请使用此代码:
config.action_controller.relative_url_root = '/redmine'
我把它放在新的 additional_environment.rb
文件。
如果您仍然希望使用反向代理使用Mongrel + Apache,我是如何在我们的系统上解决相同的问题(Win2k3,Apache 2.2,Redmine的主干)。秘诀是使用安装你的mongrel服务 --prefix /redmine
告诉它从中提供服务 http://localhost:port/redmine
在Apache httpd.conf(或合适的包含文件)中:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<IfModule mod_proxy.c>
ProxyRequests Off
#No need to forward on static content - let apache do it faster
ProxyPass /redmine/images !
ProxyPass /redmine/stylesheets !
ProxyPass /redmine/javascript !
# Remove the following entry on public sites as this is insecure
ProxyPass /redmine/plugin_assets !
ProxyPass /redmine/help !
ProxyPass /redmine http://localhost:4000/redmine
ProxyPassReverse /redmine http://localhost:4000/redmine
ProxyPreserveHost On
#continue with other static files that should be served by apache
Alias /redmine/images C:/Repositories/redmine/public/images/
Alias /redmine/stylesheets C:/Repositories/redmine/public/stylesheets/
Alias /redmine/javascript C:/Repositories/redmine/public/javascript/
# Remove the following on public sites as this is insecure
Alias /redmine/plugin_assets C:/Repositories/redmine/public/plugin_assets/
Alias /redmine/help C:/Repositories/redmine/public/help/
</IfModule>
# Make sure apache can see public and all subfolders - not suitable for public sites
<Directory "C:/Repositories/redmine/public/">
Allow from all
Order allow,deny
</Directory>
Mongrel安装如下:
mongrel_rails service::install --prefix /redmine -N redmine_prod -p 4000 -e production -c C:\Repositories\redmine
希望能帮助别人。最初,我尝试设置Apache + fastcgi等,但我失去了更多珍贵的头发 - 它不是Windows友好的。
附:我发现这个PDF非常有用: http://www.napcsweb.com/howto/rails/deployment/RailsWithApacheAndMongrel.pdf
/达米安
乘客(http://modrails.com)是fastcgi的一个更好的替代品,因为它很容易配置我建议使用它来托管你的rails应用程序使用类似于你现在拥有的配置
我同意雷达。 乘客 很容易设置,让Rails应用程序共享内存,消除管理一组mongrel的负担,几乎不需要配置。你需要的只是一个特殊的'config.ru'文件 RackUp配置 和一个DocumentRoot指向Apache中的RAILS_ROOT / public set。