WebFaction
Community site: login faq

Hi,

I have an apache mod_wsgi app. I would like to source a script that exports a bunch of env variables before runs django wsgi, so django can use these vars. I know that I can set vars with setenv in httpd.conf but I wonder if I can save to set all variables sourcing a script.

Thanks

asked 22 Dec '16, 04:58

jorrete's gravatar image

jorrete
112
accept rate: 0%


You can create a file like ~/.envs and put lines in the form of:

export VAR1="AV97hpdk6LdmJNQU"
export VAR2="False"

Then add a line to source the file at the start script, ~/webapps/<django_app>/apache2/bin/start, just before the httpd.worker one:

source $HOME/.envs

You should then be able to access those using calls like os.getenv('VAR1').

That said, the creator of mod_wsgi thinks this a bad idea and suggests using python configuration files instead.

Such environement variables will also be visable in the output of a ps command (or similar), and although other users can't see your processes, it should still be taken into account.

permanent link

answered 22 Dec '16, 13:51

iliasr's gravatar image

iliasr ♦♦
1.7k4
accept rate: 37%

edited 22 Dec '16, 13:57

Thanks, I'll go with python conf.

(22 Dec '16, 13:52) jorrete jorrete's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×220
×52
×24
×2

question asked: 22 Dec '16, 04:58

question was seen: 561 times

last updated: 22 Dec '16, 13:57

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM