相关疑难解决方法(0)

在Apache下的子目录中配置Rails 4应用程序以进行生产

我正在努力解决三个主要问题,我感谢任何帮助.

1)如何配置Rails应用程序myurl.com/myapp/作为根?

我试过routes.rb:

scope '/myapp' || '/' do
    # all resources and routes go here
    root :to => "papers#index"

    resources :papers
end 
Run Code Online (Sandbox Code Playgroud)

environment.rb,我把它添加到顶部

ENV['RAILS_RELATIVE_URL_ROOT'] = "/myapp"
Run Code Online (Sandbox Code Playgroud)

这几乎可以工作,除了rake routes不打印"/"的任何路径,并GET myurl.com/myapp/产生ActionController::RoutingError (No route matches [GET] "/")

2)告诉apache需要什么?

我的共享服务器的提供商建议将其添加到 ~/html/.htaccess

RewriteEngine on
RewriteRule ^myapp/(.*)$ /fcgi-bin/rails4/$1 [QSA,L]
Run Code Online (Sandbox Code Playgroud)

/fcgi-bin/rails4存在

#!/bin/sh

# This is needed to find gems installed with --user-install
export HOME=/home/kadrian

# Include our profile to include the right RUBY
. …
Run Code Online (Sandbox Code Playgroud)

apache deployment ruby-on-rails subdirectory ruby-on-rails-4

5
推荐指数
1
解决办法
2666
查看次数