我正在努力解决三个主要问题,我感谢任何帮助。在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
和environment.rb
,我加入这个要顶
ENV['RAILS_RELATIVE_URL_ROOT'] = "/myapp"
这几乎工作,但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]
与/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
. $HOME/.bash_profile
# This makes Rails/Rack think we're running under FastCGI. WTF?!
# See ~/.gem/ruby/1.9.1/gems/rack-1.2.1/lib/rack/handler.rb
export PHP_FCGI_CHILDREN=1
# Get into the project directory and start the Rails server
cd $HOME/rails4
exec bundle exec rails server -e production
当我点击网站上的任何链接,浏览器的网址,例如:改变到myurl.com/fcgi-bin/rails4/papers/1
,它应该是myurl.com/myapp/papers/1
。我怎样才能防止呢?
3)如何获得资产工作
我喜欢这种感觉也会莫名其妙地被加上1解决)和2)。然而,现在,该应用程序试图执行:
GET myurl.com/assets/application-5e86fb668d97d38d6994ac8e9c45d45e.css
这procudes一个404 Not Found
。资产也应该在subdirectoy下,对不对?我如何告诉轨道在那里放置/找到它们?