我需要帮助在Ubuntu 11.10服务器上运行rails应用程序。
我已经使用了大约2天,并且无法通过此处屏幕截图中显示的部分。据我所知,我有rvm,rails,ruby,capistrano,融合乘客都正确安装。我认为我的问题与数据库(mysql)有关,或者让轨道与数据库通信(我只是从下面的错误消息中猜测)。
Error message:
undefined method `active_record' for #<Rails::Application::Configuration:0x00000002e43fe8>
Exception class:
NoMethodError
Application root:
/var/www/jamesbay/blog/current
我的主要问题是如何进行调试呢? 我已经尝试修改config.ru文件,application.rb和environment.rb列出没有解决方案。我不完全确定这些错误甚至意味着什么!
我有capistrano正确部署到服务器上的目录。 我可以对git repo进行更新,并使用各种'cap'命令来处理从本地机器到服务器的实际部署。
任何帮助表示赞赏! (我只使用rails大约2周,而且由于这个项目,我已经学会了关于服务器管理的TON)
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
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/
使用的宝石 动作制造者(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) 卡皮斯特拉诺(2.13.4) 咖啡轨(3.2.2) 咖啡脚本(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) 哑剧型(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) rack-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) uglifier(1.3.0)
-
这是在刚刚在浏览器中打开应用程序后显示在日志文件中的内容:
[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>'
切换到rails 1.9.3-p194(与我的dev机器相同)并删除p286后,当我转到我的网站时,我收到一条消息,说“你正在寻找的页面不存在”。
这是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>'
答案 0 :(得分:0)
我最终解决了我的问题。
主要问题是由于使用rvm安装和管理了多个版本的ruby。 这加上没有正确初始化我的数据库而没有正确设置我的apache路径导致错误。
我的默认ruby版本设置为ruby-1.9.3-p286,但我在我的开发机器上使用ruby-1.9.3-p194。我以前在服务器上安装了两个版本,但没有选择默认版本。确保在部署之前选择默认版本。
我正在使用子URI,而我没有使用符号链接正确设置路径。例如,我的应用程序文件位于/ home / username / appName中,公共目录位于/ home / username / appName / current / public。在我的DocumentRoot,/ var / www中,我创建了一个名为'appName'的符号链接,指向公共目录路径。我搞砸的地方是没有在/ etc / apache2 / sites-available / default文件中定义RackBasedURI路径。
此处引用此流程: http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri