在Passenger上运行GraphicsMagick时出错

时间:2017-04-04 17:33:54

标签: ruby-on-rails passenger graphicsmagick

我在运行rails服务器的本地计算机上安装了GraphicsMagick和gem,它运行良好。但是,在开发服务器上,使用PassengerApache设置环境。我安装了GraphicsMagick并执行了bundle install。它确实成功安装了gem。

但是,当我访问该网站时,我收到以下错误:

There was an error while trying to load the gem 'graphicsmagick'.
Gem Load Error is: Permission denied @ rb_sysopen - mkmf.log
Backtrace for gem load error is:
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/mkmf.rb:308:in `initialize'
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/mkmf.rb:308:in `open'
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/mkmf.rb:308:in `log_open'
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/mkmf.rb:317:in `open'
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
/home/ubuntu/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/mkmf.rb:1574:in `find_executable'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/graphicsmagick-1.0.5/lib/graphicsmagick.rb:8:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `require'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `each'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `block in require'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `each'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `require'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler.rb:107:in `require'
/home/ubuntu/AdvanceX/backend/config/application.rb:7:in `<top (required)>'
/home/ubuntu/AdvanceX/backend/config/environment.rb:2:in `require'
/home/ubuntu/AdvanceX/backend/config/environment.rb:2:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
/home/ubuntu/.rvm/gems/ruby-2.3.3/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
Bundler Error Backtrace:
 (Bundler::GemRequireError)
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:90:in `block (2 levels) in require'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `each'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:86:in `block in require'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `each'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/runtime.rb:75:in `require'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler.rb:107:in `require'
  /home/ubuntu/AdvanceX/backend/config/application.rb:7:in `<top (required)>'
  /home/ubuntu/AdvanceX/backend/config/environment.rb:2:in `require'
  /home/ubuntu/AdvanceX/backend/config/environment.rb:2:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
  /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'

知道为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

问题在于运行应用的用户没有足够的permission来运行find_executable,也没有写入权限来创建mkmf.log日志文件。

添加具有足够访问权限的usergroup解决了问题。