Question

Hope you're well.

I've added a couple of environment variables to my virtualenv postactivate file, for example:

export DATABASE_USER="root"
export DATABASE_PASSWORD="12345678"

I then assign those variables in my settings.py using os.environ['DATABASE_USER'], for example

DATABASE_USER = os.environ['DATABASE_USER']

Since my Apache virtualhost file contains

WSGIDaemonProcess mysite.local python-path=/my/python/path:/path/to/my/project/venv/lib/python2.7/site-packages
WSGIProcessGroup mysite.local
WSGIScriptAlias / /path/to/my/project/wsgi.py

As I understand it, this tells mod_wsgi to run in daemon mode and which virtualenv to use. Since it knows which virtualenv to use, I would image it would run postactivate, thereby enabling my environment variables, but this however is not the case.

Am I doing something wrong? Any suggestions or recommendations are welcome.

Was it helpful?

Solution

With that configuration, all mod_wsgi is doing is adding the virtualenv site-packages directory into sys.path, nothing more.

You cannot use that as a place to set environment variables when using mod_wsgi as it is never used by mod_wsgi in any of the ways it can be configured.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top