Setting environment variables in mod_wsgi for Django
I’m running Django on an RHEL instance under Apache/mod_wsgi, and I’m having issues setting some environment variables for the Python process. All of the components (Apache, Python, mod_wsgi, external libraries) are built from source, not installed from the repos.
The specific issue is support for Oracle support. I am able to connect to Oracle instances without a problem if I set the ORACLE_HOME and LD_LIBRARY_PATH on the command line when firing up Python myself, but I can’t seem to get those variables passed through to the WSGI process.
The specific error message I get in the Apache logs is:
ImproperlyConfigured: Error loading cx_Oracle module: libclntsh.so.11.1: cannot open shared object file: No such file or
directory
I have tried setting the variables in the VirtualHost (using SetEnv), Apache’s envvars file, the apache user’s .bashrc file, and the .wsgi file (using os.environ['ORACLE_HOME']='...'), all with no effect. In the first three cases, the variables don’t seem to make to to Python at all–printing os.environ['ORACLE_HOME'] indicates that no value has been set.
I have also tried rebuilding mod_wsgi.so from source with the LD_RUN_PATH evn var set, per the advice here: http://groups.google.com/group/modwsgi/browse_thread/thread/91dfa97330dfca2/474f818304d741d4
However, that was also ineffective.
What am I missing? How can I get those env vars successfully passed through? Thanks in advance!
The key seems to have been adding the Oracle libraries to ld.so.conf.
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
- Cron expression that runs every 5 minutes from 1:30 am – 6:00 am [duplicate]
- Understanding redundant power supplies
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?





