浏览 671 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2008-05-28
由于SSL证书的原因,需要将Rails应用部署到一个已有域名下,部署后URL为:
http://www.mydomain.com/myapp 使用的web服务器是Apache 2.0 + Mongrel。 打算使用Proxy方式实现。 在网上搜索了相关资料,但一直未能成功。 所有的链接,包括javascript, stylesheet, 图片,以及action等,url都不正确。 如,controller为test, action为hello的URL,应该为http://www.mydomain.com/myapp/test/hello, 但实际是http://www.mydomain.com/test/hello。 有哪位能给出个正确部署说明吗? 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2008-05-28
修改config\routes.rb重新定义map.root
|
|
| 返回顶楼 | |
|
最后更新时间:2008-05-29
|
|
| 返回顶楼 | |
|
最后更新时间:2008-05-30
谢谢楼上兄弟的指点。
下面说一下我的修改情况: 1. 使用mongrel_rails的prefix参数(或者修改routes.rb和asset_host)。 通过以上修改后,可以使用http://localhost:3000/myapp访问了。 2. 修改apache的httpd.conf文件,添加以下几行: ProxyPass /myapp/ http://localhost:3000/myapp/ ProxyPass /myapp http://localhost:3000/myapp ProxyPassReverse /myapp/ http://localhost:3000/myapp/ 这样,可以使用http://localhost/myapp访问系统。 3. 但修改成https后,当系统中使用了重定向之后,就出现问题了。 url自动从https://localhost/myapp/controller/action/id 自动跳转到了 http://localhost/myapp/controller1/action1/id1。 哪位帮忙看下。 |
|
| 返回顶楼 | |
|
最后更新时间:2008-06-03
问题基本解决。
1. 在上面第一步中,使用mongrel_rails启动时,如果是在linux环境下,需要使用-d选项时,需要安装daemons gem: gem install daemons 2. 在第二步中,最后一个配置出错,正确配置应该是: ProxyPass /myapp/ http://localhost:3000/myapp/ ProxyPass /myapp http://localhost:3000/myapp ProxyPassReverse /myapp/ http://www.mydomain.com/myapp/ |
|
| 返回顶楼 | |
|
最后更新时间:2008-06-06
rainux 写道 http://www.benlog.org/2007/2/17/deploy-your-rails-app-in-a-subdirectory-with-apache-and-mongrel
这个网站down了,下面是google的cache 引用 Deploy your Rails app in a subdirectory with Apache and Mongrel
It’s not particularly hard to deploy your app in a subdirectory, but I’ve found that figuring out how to can be. So, I decided to put together this short little write-up. It turns out Mongrel versions 0.3.14.x and up have a —prefix command line parameter for locating your Rails app at an arbitrary URL. Of course, you should already be running version 1.0 anyways. Here’s a single production Mongrel instance running on port 8000, prefixed with ‘subdir’: mongrel_rails start -e production -p 8000 --prefix=/subdir Your app should now be accessible at http://localhost:8000/subdir. How does this work? Aside from prefixing all your routes with the ’/subdir’ path, the —prefix option also modifies the result of all url_for (and thus link_to) method calls to include the new path. That means that, given a religious use of the link_to method, you can arbitrarily relocate your program anywhere at the drop of a hat. Not bad. url_for :controller=> 'admin', :action => 'login' # => '/subdir/admin/login' I’m going to assume you’ve already figured out how to proxy Mongrel through Apache. As far as your subdirectory goes, you need the following two lines in your Apache conf file: ProxyPass /subdir http://localhost:8000/subdir ProxyPassReverse /subdir http://localhost:8000/subdir The “tricky” part here is to include the subdirectory in both the source and destination URLs of your proxy commands. Anyways, that’s it. Launch your Mongrel (cluster), restart Apache, and you’re good to go. |
|
| 返回顶楼 | |



