简体   繁体   English

如何使用Apache设置LD_LIBRARY_PATH

[英]How to set LD_LIBRARY_PATH with apache

I'm attempting to run a flask app with mod_wsgi on Ubuntu 16.04. 我正在尝试在Ubuntu 16.04上使用mod_wsgi运行flask应用程序。 I'm having a problem setting the $LD_LIBRARY_PATH$ environment variable. 我在设置$LD_LIBRARY_PATH$环境变量时遇到问题。 I'm able to set this in my ~.bashrc file, and as a result I am able to import all my libraries and dependencies without a problem. 我可以在~.bashrc文件中进行设置,因此我可以毫无问题地导入所有库和依赖项。 However it seems apache seems to erase these environment variables. 但是,似乎Apache似乎删除了这些环境变量。

The error I'm getting in my log file is the following 我在日志文件中遇到的错误如下

ImportError: libmkl_rt.so: cannot open shared object file: No such file or directory

There are two python libraries I'm importing that require mkl. 我要导入的两个Python库需要mkl。 The first doesn't seem to complain. 第一个似乎没有抱怨。 However the second library cannot be imported due to the mkl error. 但是,由于mkl错误,无法导入第二个库。

I find this odd so I recompiled the second python library after setting the $LD_RUN_PATH environment variable to the mkl paths. 我觉得很奇怪,因此在将$LD_RUN_PATH环境变量设置为mkl路径后,我重新编译了第二个python库。 However it is still unable to find mkl. 但是,它仍然找不到mkl。

How do I configure apache accordingly? 如何配置apache? All other imports work fine. 所有其他进口都可以正常工作。 I am able to run the flask scripts on their own without apache, so I'm pretty sure this is an apache problem. 我可以不使用apache单独运行flask脚本,所以我很确定这是一个apache问题。

if in you 如果在你里面

/etc/sysconfig/httpd

add something like this 添加这样的东西

LD_LIBRARY_PATH=/my/library/path

then 然后

apachectl restart httpd

should do the trick 应该可以

apache by default use system lib path. apache默认使用系统库路径。 so just add link of your so file to /usr/lib and then run command sudo ldconfig . 所以只需将您的so文件的链接添加到/usr/lib ,然后运行命令sudo ldconfig perhaps problem will resolve 也许问题会解决

also this post may be helpful https://stackoverflow.com/a/23244452/6876911 这篇文章也可能会有所帮助https://stackoverflow.com/a/23244452/6876911

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

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