Ruby on rails应用程序在生产环境中找不到JavaScript运行时(使用passenger和nginx进行部署)?

时间:2015-01-21 04:00:48

标签: javascript ruby-on-rails ruby nginx passenger

我使用ruby on railspassenger在ubuntu中部署了nginx个应用程序,但它返回了500错误。

我读了日志,这是因为Could not find a JavaScript runtime.,但是我在我的服务器上安装了node.js(它运行节点ok)。

以下是错误日志:

Could not spawn process for application /home/roger/ruby_workspace/blog: An error occured while starting up the preloader.
  Error ID: f57c8900
  Error details saved to: /tmp/passenger-error-tIcmuB.html
  Message from application: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
  /home/roger/ruby_workspace/blog/vendor/bundle/ruby/2.2.0/gems/execjs-2.2.2/lib/execjs/runtimes.rb:51:in `autodetect'
  /home/roger/ruby_workspace/blog/vendor/bundle/ruby/2.2.0/gems/execjs-2.2.2/lib/execjs.rb:5:in `<module:ExecJS>'
  /home/roger/ruby_workspace/blog/vendor/bundle/ruby/2.2.0/gems/execjs-2.2.2/lib/execjs.rb:4:in `<top (required)>'
  /home/roger/ruby_workspace/blog/vendor/bundle/ruby/2.2.0/gems/uglifier-2.7.0/lib/uglifier.rb:3:in `require'
  /home/roger/ruby_workspace/blog/vendor/bundle/ruby/2.2.0/gems/uglifier-2.7.0/lib/uglifier.rb:3:in `<top (required)>'
  /home/roger/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:76:in `require'
  /home/roger/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
  /home/roger/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:72:in `each'
  /home/roger/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:72:in `block in require'
  /home/roger/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:61:in `each'
  /home/roger/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:61:in `require'
  /home/roger/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.7.11/lib/bundler.rb:134:in `require'
  /home/roger/ruby_workspace/blog/config/application.rb:7:in `<top (required)>'
  /home/roger/ruby_workspace/blog/config/environment.rb:2:in `require'
  /home/roger/ruby_workspace/blog/config/environment.rb:2:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /home/roger/ruby_workspace/blog/vendor/bundle/ruby/2.2.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
  /home/roger/ruby_workspace/blog/vendor/bundle/ruby/2.2.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /opt/passenger/passenger-4.0.57/helper-scripts/rack-preloader.rb:112:in `eval'
  /opt/passenger/passenger-4.0.57/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /opt/passenger/passenger-4.0.57/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /opt/passenger/passenger-4.0.57/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /opt/passenger/passenger-4.0.57/helper-scripts/rack-preloader.rb:28:in `<main>'

enviroment.rb:

# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Rails.application.initialize!

1 个答案:

答案 0 :(得分:0)

Gemfile文件中添加此行: -

gem 'therubyracer'

然后: -

bundle install