Rails 3 - Windows + Mongrel (Error with dispatcher)

拟墨画扇 提交于 2020-01-06 07:46:13

问题


I am trying to deploy a rails 3 app to a windows machine (yes it has to be windows, I cannot use linux)

I decided to try and use Mongrel + Apache (willing to try other setups if anyone knows one that works).

I have mongrel installed and I can run rails server mongrel and run my app fine. However when I try to start mongrel as a windows service using

mongrel_rails service::install -N mongrel1 -e production -p 3001 -c mydirectory`

I run into trouble. The server starts fine but when I try to get onto the web page I get the following error generated in my mongrel.log file.

Error calling Dispatcher.dispatch #<NameError: uninitialized constant ActionController::CgiRequest>
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:76:in `block in process'
<internal:prelude>:10:in `synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:74:in `process'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:165:in `block in process_client'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:164:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:164:in `process_client'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:291:in `block (2 levels) in run'

I have tried to read up on this but all the setup guides seem to be very dated.


回答1:


I am running a Rails 3 app on Windows (Win7) using Apache + Mongrel. Here is perhaps another approach. In httpd.conf I set DocumentRoot as the path to my rails app. The Directory tag is then set to whatever Document Root is. Then add a VirtualHost tag as follows:

<VirtualHost localhost:80>
  Servername YourAppServer
  DocumentRoot "same path as before"
  ProxyPass / http://localhost:3000/
  ProxyPassReverse / http://localhost:3000/
  ProxyPreserveHost On
</VirtualHost>"

ServerName value I think is arbitrary.

You also need to add: LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so

I suppose that if you are using port 3001 instead of 3000, you make the appropriate substitutions.

Then start everything (from your app folder) with 'rails server -e production -p 3001' (Apache should already be running)



来源:https://stackoverflow.com/questions/10616026/rails-3-windows-mongrel-error-with-dispatcher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!