jeudi 26 mars 2015

How to set environ variables in local development with virtualenv

I am currently trying to publish via ZIP my django app to an AWS elasticbeanstalk.


As I have a local and online development enviroment I would like to make use of the environ variables, that are used anyways by AWS.


For my development environments I am already using virtualenv. Apache runs with wsgi enabled and is supposed to use such environments. Unfortunately, it does not know the environ that I have set in the bin/activate.


Django throws a 500 error, since it cannot connect to the database as it does not have access to the environ vars:



1:53.862779 2015] [wsgi:error] [pid 20639] [remote 127.0.0.1:51896] KeyError: 'RDS_DB_NAME'


If I activate my env and look into the env vars:



(myenv)[bs@debian-gohan:]/var/www/vhosts/mysite $ env | grep RDS
RDS_HOSTNAME=localhost


... and I get the others as well...


My Apache Vhost is:



<VirtualHost *:80>
WSGIDaemonProcess mysite python-path=/home/bs/envs/myenv/bin/python2.7:/home/bs/envs/myenv/lib/python2.7/site-packages
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/vhosts/main-page/mysite/wsgi.py


Does anyone have an idea why the environ vars are not seen by the apache ?





Aucun commentaire:

Enregistrer un commentaire