我用 C++ 构建了一个 .CGI。这个二进制文件依赖于一些 boost
特定文件夹中的共享库和其他资源 /usr/local/boost/
. CGI 不执行,在日志中我可以看到错误
error while loading shared libraries: libdxxx: cannot
open shared object file: No such file or dire
现在,我读过很多日志,说我必须在
httpd.conf
中设置以下,但仍然不起作用。 SetEnv LD_LIBRARY_PATH /usr/local/boost:
在我的配置中,我在配置文件的末尾“按原样”设置了这一行,而没有包含在任何
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>
我也试过(见下面的讨论)为 ldconfig 添加一个 .conf 文件,但它仍然不起作用!
#added a file called myconfig.conf conrtaining a line
/usr/local/boost
/etc/ld.conf.d/
ldconfig (as root)
我也读过
httpd
继承运行它的ROOT用户的环境变量;当我 root 时,我调用以下命令来启动 Apache 并且 LD_LIBRARY_PATH 设置正确,但仍然有问题。 /etc/init.d/httpd start
我使用的是红帽 6.2。
最佳答案
在我们的 Linux Debian 机器中,我们使用这个:
创建一个配置文件,在其中添加字符串/usr/local/boost:
/etc/ld.so.conf.d/boost.conf
然后运行:
# ldconfig
最后:
# /etc/init.d/apache2 restart
我不知道如何在 Red Hat 中做到这一点。
关于apache - 用于 Apache cgi 脚本的 LD_LIBRARY_PATH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19489333/