简体   繁体   English

在Ubuntu Server上设置Rails时Phusion Passenger错误

[英]Error with Phusion Passenger while setting up Rails on Ubuntu Server

I need help getting a rails app running on an Ubuntu 11.10 Server. 我需要帮助以使Ubuntu应用程序在Ubuntu 11.10服务器上运行。

I have been at it for about 2 days and can't get past the part shown in the screen shot here. 我已经处理了大约2天,无法超越此处的屏幕截图中显示的部分。 I have rvm, rails, ruby, capistrano, fusion passenger all installed correctly as far as I can tell. 据我所知,我已经正确安装了rvm,rails,ruby,capistrano和Fusion乘客。 I think the issue I have has to do with the database (mysql) or getting rails to talk to the database (I'm just making a guess from the error messages below). 我认为我的问题与数据库(mysql)或使Rails与数据库进行通信有关(我只是从下面的错误消息中进行猜测)。

Error message:
undefined method `active_record' for #<Rails::Application::Configuration:0x00000002e43fe8>
Exception class:
NoMethodError
Application root:
/var/www/jamesbay/blog/current

My main question is how can I go about debugging this? 我的主要问题是如何进行调试? I have tried modifying the config.ru file, application.rb, and environment.rb as listed with no resolution. 我尝试修改config.ru文件,application.rb和environment.rb,但没有解决方法。 I'm not entirely sure what these errors even imply! 我不确定这些错误甚至意味着什么!

I have capistrano deploying to my directory on the server properly. 我已将capistrano正确部署到服务器上的目录中。 I can make updates to a git repo and use the various 'cap' commands to handle the actual deployment from local machine to server. 我可以对git repo进行更新,并使用各种“ cap”命令来处理从本地计算机到服务器的实际部署。

Any help is appreciated! 任何帮助表示赞赏! (I have only been using rails for about 2 weeks and I have already learned a TON about server management due to this project) (由于这个项目,我仅使用rails已有大约2周的时间,并且我已经学到了有关服务器管理的大量知识)

Errors 失误

0   /usr/local/rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/railtie/configuration.rb  85  in `method_missing'
1   /home/jamesbay/blog/releases/20121026055113/config/application.rb   54  in `'
2   /home/jamesbay/blog/releases/20121026055113/config/application.rb   13  in `'
3   /home/jamesbay/blog/releases/20121026055113/config/application.rb   12  in `'
4   /home/jamesbay/blog/releases/20121026055113/config/environment.rb   2   in `require'
5   /home/jamesbay/blog/releases/20121026055113/config/environment.rb   2   in `'
6   config.ru   3   in `require'
7   config.ru   3   in `block in '
8   /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb 51  in `instance_eval'
9   /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb 51  in `initialize'
10  config.ru   1   in `new'
11  config.ru

Setup 设定

Rails 3.2.8
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
rvm 1.16.17 (stable)
Capistrano 2.13.4
Phusion Passenger 3.0.17

RubyGems Environment:

- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p194
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
 - /usr/local/rvm/gems/ruby-1.9.3-p194
 - /usr/local/rvm/gems/ruby-1.9.3-p194@global
- GEM CONFIGURATION:
 - :update_sources => true
 - :verbose => true
 - :benchmark => false
 - :backtrace => false
 - :bulk_threshold => 1000
- REMOTE SOURCES:
 - http://rubygems.org/

Gems used actionmailer (3.2.8) actionpack (3.2.8) activemodel (3.2.8) activerecord (3.2.8) activeresource (3.2.8) activesupport (3.2.8) arel (3.0.2) bcrypt-ruby (3.0.1) builder (3.0.4) bundler (1.2.1) capistrano (2.13.4) coffee-rails (3.2.2) coffee-script (2.2.0) coffee-script-source (1.4.0) erubis (2.7.0) execjs (1.4.0) highline (1.6.15) hike (1.2.1) i18n (0.6.1) journey (1.0.4) jquery-rails (2.1.3) json (1.7.5) mail (2.4.4) mime-types (1.19) multi_json (1.3.6) mysql2 (0.3.11) net-scp (1.0.4) net-sftp (2.0.5) net-ssh (2.6.1) net-ssh-gateway (1.1.0) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) rack-ssl (1.3.2) rack-test (0.6.2) rails (3.2.8) railties (3.2.8) rake (0.9.2.2) rdoc (3.12) rubygems-bundler (1.1.0) rvm (1.11.3.5) sass (3.2.1) sass-rails (3.2.5) sprockets (2.1.3) sqlite3 (1.3.6) thor (0.16.0) tilt (1.3.3) treetop (1.4.11) tzinfo (0.3.33) uglifier (1.3.0) 使用的宝石actionmailer(3.2.8)actionpack(3.2.8)activemodel(3.2.8)activerecord(3.2.8)activeresource(3.2.8)activesupport(3.2.8)arel(3.0.2)bcrypt-ruby(3.0。 1)生成器(3.0.4)捆绑器(1.2.1)capistrano(2.13.4)咖啡轨(3.2.2)coffee-script(2.2.0)coffee-script-source(1.4.0)erubis(2.7。 0)execjs(1.4.0)高线(1.6.15)加息(1.2.1)i18n(0.6.1)旅程(1.0.4)jquery-rails(2.1.3)json(1.7.5)邮件(2.4。 4)MIME类型(1.19)multi_json(1.3.6)mysql2(0.3.11)net-scp(1.0.4)net-sftp(2.0.5)net-ssh(2.6.1)net-ssh-gateway( 1.1.0)多语言(0.3.3)机架(1.4.1)机架缓存(1.2)机架SSL(1.3.2)机架测试(0.6.2)导轨(3.2.8)导轨(3.2.8)耙(0.9.2.2)rdoc(3.12)rubygems-bundler(1.1.0)rvm(1.11.3.5)sass(3.2.1)sass-rails(3.2.5)链轮(2.1.3)sqlite3(1.3.6)雷神(0.16.0)倾斜(1.3.3)树梢(1.4.11)tzinfo(0.3.33)碎粉机(1.3.0)

-- -

This is what shows up in the log file after opening the app in a browser just now: 这是刚才在浏览器中打开应用程序后在日志文件中显示的内容:

    [Fri Oct 26 07:46:15 2012] [notice] Graceful restart requested, doing restart
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gd.so' - /usr/lib/php5/20090626/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/mcrypt.so' - /usr/lib/php5/20090626/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
    [Fri Oct 26 07:46:15 2012] [notice] Apache/2.2.20 (Ubuntu) DAV/2 SVN/1.6.12 PHP/5.3.6-13ubuntu3.7 with Suhosin-Patch Phusion_Passenger/3.0.17 configured -- resuming normal operations
    [ pid=30885 thr=4411480 file=utils.rb:176 time=2012-10-26 12:56:40.708 ]: *** Exception NoMethodError in PhusionPassenger::Rack::ApplicationSpawner (undefined method `active_record' for #<Rails::Application::Configuration:0x00000001931f38>) (process 30885, thread #<Thread:0x0000000086a0b0>):
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing'
            from /home/jamesbay/blog/releases/20121026055113/config/application.rb:54:in `<class:Application>'
            from /home/jamesbay/blog/releases/20121026055113/config/application.rb:13:in `<module:Blog>'
            from /home/jamesbay/blog/releases/20121026055113/config/application.rb:12:in `<top (required)>'
            from /home/jamesbay/blog/releases/20121026055113/config/environment.rb:2:in `require'
            from /home/jamesbay/blog/releases/20121026055113/config/environment.rb:2:in `<top (required)>'
            from config.ru:3:in `require'
            from config.ru:3:in `block in <main>'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
            from config.ru:1:in `new'
            from config.ru:1:in `<main>'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:225:in `eval'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:225:in `load_rack_app'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:157:in `block in initialize_server'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/utils.rb:563:in `report_app_init_status'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:154:in `initialize_server'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:204:in `start_synchronously'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:180:in `start'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
            from <internal:prelude>:10:in `synchronize'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
            from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/helper-scripts/passenger-spawn-server:99:in `<main>'

After switching to rails 1.9.3-p194 (same as my dev machine) and removing p286, I get a message saying "the page you were looking for doesn't exist" in RED when I goto my site. 切换到Rails 1.9.3-p194(与我的开发机相同)并删除p286后,当我转到网站时,我收到一条消息,说“ RED中不存在您要查找的页面”。

This is the output of the error.log file: 这是error.log文件的输出:

Rails Error: Unable to access log file. Please ensure that /home/jamesbay/blog/releases/20121026205006/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.

ActionController::RoutingError (No route matches [GET] "/jamesbay"):
  actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
  rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
  rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  railties (3.2.8) lib/rails/engine.rb:479:in `call'
  railties (3.2.8) lib/rails/application.rb:223:in `call'
  railties (3.2.8) lib/rails/railtie/configurable.rb:30:in `method_missing'
  passenger (3.0.17) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  passenger (3.0.17) lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
  passenger (3.0.17) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
  passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
  passenger (3.0.17) lib/phusion_passenger/utils.rb:470:in `safe_fork'
  passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
  passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:180:in `start'
  passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
  passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
  passenger (3.0.17) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
  passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
  passenger (3.0.17) lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
  <internal:prelude>:10:in `synchronize'
  passenger (3.0.17) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
  passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
  passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
  passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.17) helper-scripts/passenger-spawn-server:99:in `<main>'

I ended up resolving my issue. 我最终解决了我的问题。

The primary issue was due to having multiple versions of ruby installed and managed with rvm. 主要问题是由于使用rvm安装和管理了多个版本的ruby。 This coupled with not properly initializing my database AND not setting up my apache paths properly led to the errors. 这再加上没有正确初始化我的数据库,而不是建立我的Apache路径正确导致的错误。

My default ruby version was set to ruby-1.9.3-p286 but I was using ruby-1.9.3-p194 on my development machine. 我的默认ruby版本设置为ruby-1.9.3-p286,但是我在开发机上使用ruby-1.9.3-p194。 I had previously installed both versions on the server but didn't pick a default. 我以前在服务器上安装了两个版本,但未选择默认版本。 Make sure you pick a default version before deployment. 确保在部署之前选择默认版本。

I am using sub URI's and I hadn't set up the paths properly with symlinks. 我正在使用子URI,但没有使用符号链接正确设置路径。 For example, I have my application files inside /home/username/appName, with the public directory living at /home/username/appName/current/public. 例如,我的应用程序文件位于/ home / username / appName中,而公共目录位于/ home / username / appName / current / public中。 Inside my DocumentRoot, /var/www I created a symlink called 'appName' that points to the public directory path. 在我的DocumentRoot中,/ var / www创建了一个名为“ appName”的符号链接,该符号链接指向公共目录路径。 Where I messed up was in not defining the RackBasedURI path in my /etc/apache2/sites-available/default file. 我搞砸的地方是没有在我的/ etc / apache2 / sites-available / default文件中定义RackBasedURI路径。

This process is referenced here: http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri 此处引用了此过程: http : //www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM