0
我想使用Rails + nginx + unicorn + MongoDB在7個子域中設置7個目錄。使用ActionController(GET)的RoutingError
實際上,子域是由nginx從根文件生成的,並且完美地工作,並且我還沒有使用MongoDB。 安裝剛剛製作,尚未創建任何頁面(我也嘗試過),並且在日誌中仍然有404錯誤。 當然,如果我在/public
中創建了一個html頁面,就可以工作。
實施例:
我在/var/www/site1
可用使用rails new site1
上http://site1.mydomain.tld
安裝它們中的一個將在/var/www/site1/log/production.log
顯示這個錯誤:
I, [2013-09-01T02:12:44.425694 #31368] INFO -- : Started GET "/" for XXX.XXX.XXX.XXX at 2013-09-01 02:12:44 +0200
F, [2013-09-01T02:12:44.426541 #31368] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/"):
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
unicorn (4.6.3) lib/unicorn/http_server.rb:552:in `process_client'
unicorn (4.6.3) lib/unicorn/http_server.rb:632:in `worker_loop'
unicorn (4.6.3) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
unicorn (4.6.3) lib/unicorn/http_server.rb:142:in `start'
unicorn (4.6.3) bin/unicorn:126:in `<top (required)>'
/usr/local/bin/unicorn:23:in `load'
/usr/local/bin/unicorn:23:in `<main>'
有我的Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'bson_ext'
# mongoDB tool
## gem 'mongoid', '~> 3.0.0'
## gem 'mongo', '~> 1.9.2'
#gem 'mongo_mapper'
gem 'sqlite3'
# Use unicorn as the app server
gem 'unicorn'
# CSS tool
gem 'sass-rails', '~> 4.0.0'
## JQUERY & javascript stuff
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use debugger
# gem 'debugger', group: [:development, :test]
我config/unicorn.rb
文件:
root = "/var/www/site1"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/uni-err.log"
stdout_path "#{root}/log/uni-out.log"
listen "/tmp/site1-unicorn.test.sock"
worker_processes 2
timeout 30
任何幫助將是有益的。謝謝!
不幸的是,我剛剛嘗試過。它並沒有改變任何東西。至少,現在我知道所有服務在啓動時都能正確啓動! 但我仍然從Rails公用文件夾中獲取404頁... – Psype
什麼是您的路由文件? –
'Site1 :: Application.routes.draw do ''index'':'hello#index' end' ...但我剛剛看到演示可以在端口3000上使用Rails服務器。所以這可能是一個與Unicorn(或nginx?)相關的問題 – Psype