我正在努力解決三個主要問題,我感謝任何幫助。在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下,對不對?我如何告訴軌道在那裏放置/找到它們?