用于 Apache cgi 脚本的 LD_LIBRARY_PATH

Abr*_*ile 4 apache cgi environment-variables cgi-bin

我用 C++ 构建了一个 .CGI。此二进制文件依赖于boost特定文件夹中的某些共享库和其他资源/usr/local/boost/。CGI 不执行,在日志中我可以看到错误

    error while loading shared libraries: libdxxx: cannot 
    open shared object file: No such file or dire
Run Code Online (Sandbox Code Playgroud)

现在,我读了很多日志,说我必须在httpd.conf下面进行设置,但仍然不起作用。

   SetEnv LD_LIBRARY_PATH /usr/local/boost:
Run Code Online (Sandbox Code Playgroud)

在我的配置中,我在配置文件的末尾“按原样”设置了这一行,而没有包含在任何VirtualHOst or Directory部分中。我试图插入到 cgi-bin 的目录中,但还是一样

 <Directory "/var/www/cgi-bin">
     AllowOverride None
     Options None
     Order allow,deny
     Allow from all
     SetEnv LD_LIBRARY_PATH /usr/local/boost
 </Directory>
Run Code Online (Sandbox Code Playgroud)

我也试过(见下面的讨论)为 ldconfig 添加一个 .conf 文件,但它仍然不起作用!

  #added a file called myconfig.conf conrtaining a line
  /usr/local/boost 

  /etc/ld.conf.d/
  ldconfig (as root)
Run Code Online (Sandbox Code Playgroud)

我还阅读了httpd继承运行它的 ROOT 用户的环境变量;当我 root 时,我调用以下命令来启动 Apache 并且 LD_LIBRARY_PATH 设置正确,但仍然有问题。

 /etc/init.d/httpd start
Run Code Online (Sandbox Code Playgroud)

我使用的是红帽 6.2。

jac*_*ouh 5

在我们的 Linux Debian 盒子中,我们使用这个:

创建一个配置文件,在其中添加字符串 /usr/local/boost:

/etc/ld.so.conf.d/boost.conf
Run Code Online (Sandbox Code Playgroud)

然后运行:

# ldconfig
Run Code Online (Sandbox Code Playgroud)

最后:

# /etc/init.d/apache2 restart
Run Code Online (Sandbox Code Playgroud)

我不知道如何在 Red Hat 中做到这一点。