FCGI Ruby Gem not found when using apache

193 Views Asked by At

I am using Apache with FastCGI to run a ruby application. I have installed the apache fcgi module and also the Ruby fcgi gem.

When I run the fcgi script 'search.fcgi' like so

ruby search.fcgi

It runs successfully. However when starting Apache I get the following error in my log file when it tries to run the same script:

/usr/local/rvm/rubies/ruby-2.1.8/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- fcgi (LoadError)
from /usr/local/rvm/rubies/ruby-2.1.8/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/user/fcgi/search.fcgi:13:in `<main>'

Line 13 in search.fcgi is simply require 'fcgi'

It appears as though when running through Apache it is unable to detect the installed gem. I have loaded irb and and run require 'fcgi' which returns true.

Am I missing something here? Some path or config item I need to set?

1

There are 1 best solutions below

0
On

My problem was caused by the fact that Ruby was installed using RVM. There was some issue with the script from apache accessing some parts of the RVM instillation. The solution was to remove the RVM ruby install and reinstall ruby from source.