简体   繁体   English

apache不尊重LD_LIBRARY_PATH?

[英]apache doesn't respect LD_LIBRARY_PATH?

In my web application I have this piece of code: 在我的Web应用程序中,我有这段代码:

from rdkit import Chem

This causes it to crash under apache, in logs I can see: 这导致它在apache下崩溃,在我可以看到的日志中:

[Fri Sep 06 10:35:44 2013] [error] [client 172.22.69.51] ImportError: libRDGeneral.so.1: cannot open shared object file: No such file or directory

It looks like this problem is caused by LD_LIBRARY_PATH but I set it in my wsgi.py file: 看起来这个问题是由LD_LIBRARY_PATH引起的,但我在我的wsgi.py文件中设置它:

os.environ['LD_LIBRARY_PATH']='/usr/lib/oracle/11.2/client64/lib:/nfs/public/rw/chembl/utils/RDKit_2012_09_1/lib:/nfs/public/rw/chembl/utils/indigo/lib/Linux/x64/'

as well as in VirtualHost apache conf: 以及在VirtualHost apache conf中:

<VirtualHost *:8787>
    ...
SetEnv LD_LIBRARY_PATH /usr/lib/oracle/11.2/client64/lib:/nfs/public/rw/chembl/utils/RDKit_2012_09_1/lib:/nfs/public/rw/chembl/utils/indigo/lib/Linux/x64/
</VirtualHost>

I can run this without problems from command line on the same machine: 我可以在同一台机器上从命令行运行它没有问题:

(chembl_webservices)-bash-4.1$ export PYTHONPATH=/nfs/public/rw/chembl/utils/RDKit_2012_09_1/
(chembl_webservices)-bash-4.1$ export LD_LIBRARY_PATH=/nfs/public/rw/chembl/utils/RDKit_2012_09_1/lib
(chembl_webservices)-bash-4.1$ /nfs/public/rw/chembl/utils/virtualenvs/ldc/envs/chembl_webservices/bin/python
Python 2.7.5 (default, Aug  5 2013, 17:00:57) 
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import rdkit
from rdkit import Chem

And of course I can make my script print actual value of LD_LIBRARY_PATH so I know it's set correctly, the file and path exists and privileges are fine: 当然我可以让我的脚本打印LD_LIBRARY_PATH的实际值,所以我知道它设置正确,文件和路径存在,权限很好:

ls /nfs/public/rw/chembl/utils/RDKit_2012_09_1/lib -lh
-rwxr-xr-x 1 cbl_adm cbl_pub 406K Aug  8 11:13 libRDGeneral.so.1.2012.09.1

I can run ldd libRDGeneral.so.1.2012.09.1 to see that all dependencies are met: 我可以运行ldd libRDGeneral.so.1.2012.09.1来查看是否满足所有依赖项:

linux-vdso.so.1 =>  (0x00007fff397ff000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f096ecd5000)
libm.so.6 => /lib64/libm.so.6 (0x00007f096ea50000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f096e83a000)
libc.so.6 => /lib64/libc.so.6 (0x00007f096e4a7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f096f22d000)

So what's wrong? 那有什么不对? What else can I do? 我还可以做些什么? How can I debug it? 我该怎么调试呢? Please help. 请帮忙。

The LD_LIBRARY_PATH must be set in the environment outside of the Apache process when Apache is started. 启动Apache时,必须在Apache进程外部的环境中设置LD_LIBRARY_PATH。 It cant be set inside of your web application after Apache has been started. 在Apache启动后,它无法在Web应用程序中设置。

What you should do is recompile the rdkit module and set: 你应该做的是重新编译rdkit模块并设置:

LD_RUN_PATH=/nfs/public/rw/chembl/utils/RDKit_2012_09_1/lib

in the environment when compiling it. 在编译环境时。 Setting LD_RUN_PATH at compile time of the Python C extension module will cause that directory to be embedded in the Python C extension module so that it knows where to find the library at run time without LD_LIBRARY_PATH needing to be set. 在Python C扩展模块的编译时设置LD_RUN_PATH将导致该目录嵌入到Python C扩展模块中,以便它知道在运行时在何处找到库而不需要设置LD_LIBRARY_PATH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM