简体   繁体   中英

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.

I have been at it for about 2 days and can't get past the part shown in the screen shot here. I have rvm, rails, ruby, capistrano, fusion passenger all installed correctly as far as I can tell. 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).

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. I'm not entirely sure what these errors even imply!

I have capistrano deploying to my directory on the server properly. I can make updates to a git repo and use the various 'cap' commands to handle the actual deployment from local machine to server.

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)

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)

--

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.

This is the output of the error.log file:

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. This coupled with not properly initializing my database AND not setting up my apache paths properly led to the errors.

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. 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. For example, I have my application files inside /home/username/appName, with the public directory living at /home/username/appName/current/public. Inside my DocumentRoot, /var/www I created a symlink called 'appName' that points to the public directory path. Where I messed up was in not defining the RackBasedURI path in my /etc/apache2/sites-available/default file.

This process is referenced here: http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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