I have a developed flask application which runs successfully on flask's embedded server. The application uses a backend written in C++. The libraries for my C++ backend are in this folder:
/home/(USER_NAME)/rf/Dev/Backend/lib/libtestCAF.so
When I run the application on the embedded server, it finds the C++ backend code and uses it to generate reports. However, when I run the same application on apache, I get this error trace:
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] from main.main import main
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] File "/home/(USER_NAME)/rf/Dev/Web/main/main.py", line 19, in <module>
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] from CAF.CAFWrapper import *
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] File "/home/admin1/rf/Dev/Web/CAF/CAFWrapper.py", line 12, in <module>
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] lib = cdll.LoadLibrary('../Backend/lib/libtestCAF.so')
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] return self._dlltype(name)
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] self._handle = _dlopen(self._name, mode)
[Thu Jul 11 14:44:54 2013] [error] [client 127.0.0.1] OSError: ../Backend/lib/libtestCAF.so: cannot open shared object file: No such file or directory
As you can see on that last line, it says that libtestCAF.so doesn't exist. Meanwhile, the embedded server always finds it.
I use mod_wsgi to run the flask application on the apache server. The WSGI file I use is in this folder:
/home/(USER_NAME)/rf/Dev/Web/wsgi/rf.wsgi
... and it says this:
import sys
sys.path.insert(0,'home/(USER_NAME)/rf/Dev/Web')
from runserver import app as application
This is my apache config file:
<VirtualHost *:8100>
ServerName www.relativefinder.com
WSGIDaemonProcess rf user=www-data group=www-data threads=5
WSGIScriptAlias / /home/(USER_NAME)/rf/Dev/Web/wsgi/rf.wsgi
<Directory /home/(USER_NAME)/rf/Dev>
WSGIProcessGroup rf
WSGIApplicationGroup %{GLOBAL}
Options Indexes FollowSymLinks MultiViews
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
The python file which loads the .so files uses the following code:
if SettingsToUse == DEV_CAF:
lib = cdll.LoadLibrary('../Backend/lib/librelativefinder.so')
else:
lib = cdll.LoadLibrary('../Backend/lib/libtestCAF.so')
I'm quite confused that Apache doesn't seem to find it but the embedded server in flask always appears to find it. What do I need to do so that, when I run apache, it will find that .so file?