I need help getting a rails app running on an Ubuntu 11.10 Server.
我需要帮助在Ubuntu 11.10服务器上运行rails应用程序。
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).
我已经使用了大约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
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!
我的主要问题是如何进行调试呢?我已经尝试修改config.ru文件,application.rb和environment.rb列出没有解决方案。我不完全确定这些错误甚至意味着什么!
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.
我有capistrano正确部署到服务器上的目录。我可以更新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周了,由于这个项目,我已经学会了关于服务器管理的TON)
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)
Gems使用了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)加息(1.2.1)i18n(0.6.1)旅程(1.0.4)jquery-rails(2.1.3)json(1.7.5)邮件(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)多语言(0.3.3)机架(1.4.1)机架缓存(1.2)rack-ssl(1.3.2)机架测试(0.6.2)导轨(3.2.8)铁路(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)链轮(2.1.3)sqlite3(1.3.6) thor(0.16.0)倾斜(1.3.3)树顶(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.
切换到rails 1.9.3-p194(与我的开发机器相同)并删除p286后,当我转到我的网站时,我收到一条消息,说“你正在寻找的页面不存在”。
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>'
1 个解决方案
#1
0
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.
主要问题是由于使用rvm安装和管理了多个版本的ruby。这加上没有正确初始化我的数据库而没有正确设置我的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. I had previously installed both versions on the server but didn't pick a default. Make sure you pick a default version before deployment.
我的默认ruby版本设置为ruby-1.9.3-p286,但我在我的开发机器上使用ruby-1.9.3-p194。我以前在服务器上安装了两个版本但没有选择默认版本。确保在部署之前选择默认版本。
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.
我正在使用子URI,我没有使用符号链接正确设置路径。例如,我的应用程序文件位于/ home / username / appName中,公共目录位于/ home / username / appName / current / public。在我的DocumentRoot,/ var / www中,我创建了一个名为'appName'的符号链接,指向公共目录路径。我搞砸的地方是没有在/ 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
#1
0
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.
主要问题是由于使用rvm安装和管理了多个版本的ruby。这加上没有正确初始化我的数据库而没有正确设置我的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. I had previously installed both versions on the server but didn't pick a default. Make sure you pick a default version before deployment.
我的默认ruby版本设置为ruby-1.9.3-p286,但我在我的开发机器上使用ruby-1.9.3-p194。我以前在服务器上安装了两个版本但没有选择默认版本。确保在部署之前选择默认版本。
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.
我正在使用子URI,我没有使用符号链接正确设置路径。例如,我的应用程序文件位于/ home / username / appName中,公共目录位于/ home / username / appName / current / public。在我的DocumentRoot,/ var / www中,我创建了一个名为'appName'的符号链接,指向公共目录路径。我搞砸的地方是没有在/ 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