'How to set LD_LIBRARY_PATH with apache

I'm attempting to run a flask app with mod_wsgi on Ubuntu 16.04. I'm having a problem setting the $LD_LIBRARY_PATH$ environment variable. 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. However it seems apache seems to erase these environment variables.

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. The first doesn't seem to complain. However the second library cannot be imported due to the mkl error.

I find this odd so I recompiled the second python library after setting the $LD_RUN_PATH environment variable to the mkl paths. However it is still unable to find mkl.

How do I configure apache accordingly? 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.



Solution 1:[1]

if in you

/etc/sysconfig/httpd

add something like this

LD_LIBRARY_PATH=/my/library/path

then

apachectl restart httpd

should do the trick

Solution 2:[2]

apache by default use system lib path. so just add link of your so file to /usr/lib and then run command sudo ldconfig. perhaps problem will resolve

also this post may be helpful https://stackoverflow.com/a/23244452/6876911

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fliman
Solution 2 Community