Trouble setting LD_LIBRARY_PATH for FastCGI script

Hello -

I’m trying to exec a ruby script via FastCGI (on Apache 2.0), and cannot
properly set the env. variable LD_LIBRARY_PATH at run time.

I’ve tried adding:

SetEnv LD_LIBRARY_PATH /path/to/lib

in a .htaccess file, but to no avail. Perl, however, happily recognizes
it.
Setting ENV[‘LD_LIBRARY_PATH’] does not take effect either.

In the error_log, I see:

[Thu Jul 20 11:32:33 2006] [warn] FastCGI: (dynamic) server
“/web/server_root/fcgi-bin/index.fcgi” restarted (pid 11242)
/path/to/ruby_bin/lib/ruby/site_ruby/1.8/i686-linux/fcgi.so:
libfcgi.so.0:
cannot open shared object file: No such file or directory -
/path/to/ruby_bin/lib/ruby/site_ruby/1.8/i686-linux/fcgi.so (LoadError)
from
/path/to/ruby_bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require’
from /path/to/index.fcgi:23

Strangely, when I execute the fcgi script from the command line, as:

$ LD_LIBRARY_PATH=/path/to/lib ./index/fcgi

I receive:

./index.fcgi:25: undefined method `each_cgi’ for FCGI:Class
(NoMethodError)

Which is particularly vexing. This configuration works on another
machine,
where the libraries are not in ‘special’ places.

Any advice on how to get Ruby to find the correct library?

-c-

Chris Gansen writes:

Hello -

I’m trying to exec a ruby script via FastCGI (on Apache 2.0), and
cannot
properly set the env. variable LD_LIBRARY_PATH at run time.

I’ve tried adding:

SetEnv LD_LIBRARY_PATH /path/to/lib

in a .htaccess file, but to no avail. Perl, however, happily
recognizes it.
Setting ENV[‘LD_LIBRARY_PATH’] does not take effect either.

I set this in Apache’s httpd.conf file, in the
declaration. You will also want to make sure you declare all the
libraries needed. If you just declare “/path/to/lib”, the libraries
wouldn’t necessarily know where to find libraries in /usr/lib, for
example. Here is the line I used (on my Solaris system):
SetEnv LD_LIBRARY_PATH
/usr/lib:/usr/local/lib:/usr/openwin/lib:/usr/local/pgsql/lib

(Probably don’t really need the /usr/openwin/lib, but…)
You would have to restart Apache, but I expect you would have to do
that anyways if one could set the same thing in the .htaccess.

In the error_log, I see:

[Thu Jul 20 11:32:33 2006] [warn] FastCGI: (dynamic) server
“/web/server_root/fcgi-bin/index.fcgi” restarted (pid 11242)
/path/to/ruby_bin/lib/ruby/site_ruby/1.8/i686-linux/fcgi.so:
libfcgi.so.0:
cannot open shared object file: No such file or directory -
/path/to/ruby_bin/lib/ruby/site_ruby/1.8/i686-linux/fcgi.so
(LoadError)
from

/path/to/ruby_bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in

`require’
from /path/to/index.fcgi:23

Strangely, when I execute the fcgi script from the command line, as:

$ LD_LIBRARY_PATH=/path/to/lib ./index/fcgi

I receive:

./index.fcgi:25: undefined method `each_cgi’ for FCGI:Class
(NoMethodError)

Which is particularly vexing. This configuration works on another
machine,
where the libraries are not in ‘special’ places.

Any advice on how to get Ruby to find the correct library?

-c-

Are you sure you’ve installed FastCGI on this system? Based on what I
see in the log file:

  1. The server cannot find libfcgi.so.0, which is installed with
    FastCGI. Make sure the file is present.
  2. You’ve probably installed ruby-fcgi since it knew about
    FCGI:Class, but the fcgi.so file would require the libfcgi.so library.
    Did you copy the ruby libraries over, but not the system libraries?

Coey


Coey M.
Senior Test Engineer
(651) 628-2831
[email protected]

Secure Computing®
Securing Connections between People, Applications, and Networks™
http://www.securecomputing.com
NASDAQ: SCUR

*** The information contained in this email message may be privileged,
confidential and protected from disclosure. If you are not the intended
recipient, any review, dissemination, distribution or copying is
strictly prohibited. If you have received this email message in error,
please notify the sender by reply email and delete the message and any
attachments. ***

On 7/20/06, Coey M. [email protected] wrote:

I set this in Apache’s httpd.conf file, in the
declaration. You will also want to make sure you declare all the
libraries needed. If you just declare “/path/to/lib”, the libraries
wouldn’t necessarily know where to find libraries in /usr/lib, for
example. Here is the line I used (on my Solaris system):
SetEnv LD_LIBRARY_PATH
/usr/lib:/usr/local/lib:/usr/openwin/lib:/usr/local/pgsql/lib

Unfortunately, I’m in a very restrictive environment, for multiple
reasons.
There are no vhosts, and custom configuration directives must either be
in
.htaccess or a stanza. It’s my understanding that .htaccess
would have the same effect as setting it in , though.
Furthermore, when I run a Perl fcgi script to dump $ENV, I see the
SetEnv
value:

LD_LIBRARY_PATH => /path/to/fcgi_bin/lib

see in the log file:

  1. The server cannot find libfcgi.so.0, which is installed with
    FastCGI. Make sure the file is present.
  2. You’ve probably installed ruby-fcgi since it knew about
    FCGI:Class, but the fcgi.so file would require the libfcgi.so library.
    Did you copy the ruby libraries over, but not the system libraries?

FastCGI is installed, but not in the typical fashion. I have the
FastCGI
libraries, libfcgi.so.0, etc installed in a user directory, which is why
I’m
trying to set LD_LIBRARY_PATH, so Ruby will look for the libraries in
the
right place. And no, I cannot install into the system library
(/usr/lib).

Thanks for the help,
–chris

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs