[英]Configuring a Rails 4 app for production in a subdirectory under Apache
[英]Configuring Ruby On Rails App in a subdirectory under Apache
我在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
文件中。
如果您仍然希望使用反向代理使用Mongrel + Apache,我是如何在我们的系统(Win2k3,Apache 2.2,Redmine的主干)上解决相同的问题。 秘诀是使用--prefix /redmine
安装你的mongrel服务,告诉它从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友好的。
Ps我发现这个PDF是一个非常有用的参考文献: http : //www.napcsweb.com/howto/rails/deployment/RailsWithApacheAndMongrel.pdf
/达米安
Passenger( http://modrails.com )是fastcgi的一个更好的替代品,因为它非常容易配置我建议使用它来托管你的rails应用程序使用类似于你现在拥有的配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.