2

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!

4 Answers 4

4

In Ubuntu, placing

export ORACLE_HOME=<your oracle home>
export LD_LIBRARY_PATH=<your library path>

in /etc/apache2/envvars seems to do the trick.

If nothing else helps, you can edit your Apache startup scripts and put above export lines just before Apache daemon startup (I recall I did something like this looong time ago on Debian).

1

Since you built Apache from source code, you could have added to the 'envvars' file in same directory as 'httpd' executable the lines:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/some/path/to/oracle/lib/directory
export LD_LIBRARY_PATH

The LD_RUN_PATH method when compiling mod_wsgi should also work, but since you don't show the exact methods you used, ie., commands executed, to try and get that work, can't comment on why it didn't work. It would be of the form though:

make distclean
./configure
LD_RUN_PATH=some/path/to/oracle/lib/directory make
sudo make install

So, set LD_RUN_PATH in same line when running 'make'. If you set it seperately as environment variable before running 'make', you must 'export' the environment variable else make will not pass it through to compiler.

0

The key seems to have been adding the Oracle libraries to ld.so.conf.

0

Another possible solution is to set LD_LIBRARY_PATH in the start up script -- e.g. in /etc/init.d/httpd:

export ORACLE_HOME=<your oracle home>
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .