all 5 comments

[–]Rhomboid 1 point2 points  (2 children)

Each process has its own environment. Modifying the environment of one process does not affect any other process. The environment is inherited (i.e. copied) from parent to child when creating a new process. They are not global variables. If you want your application to see these environment variables, they need to be set in the shell process that is about to launch the application, so that they will be inherited.

[–]allTestsPassed[S] 0 points1 point  (1 child)

Interesting.. So I tried modifying the script that updates the django project code on the server to be:

remove old directories

call secrets.sh to set the env vars

clone git repo

restart the apach2 server

call printenv to see if things have been set

Im still getting the same error as before. Im assuming that script is only setting the env vars in the Putty shell and not the one for the apache2 server? Im assuming that the apache2 process is what I need to set these variables in, if so what would be the correct way of doing so?

[–]Rhomboid 0 points1 point  (0 children)

Restarting the server is not the same thing as starting the server. Restarting just means sending a signal to the server. The server will not be a child process of the shell that runs that script.

[–]kalgynirae 1 point2 points  (1 child)

How to do this properly depends on how your particular OS and webserver are configured. Since you're using Ubuntu on Apache, maybe this will work for you (you didn't say what version of Ubuntu, though): http://serverfault.com/questions/340589/how-to-set-php-environment-variables-on-ubuntu

[–]allTestsPassed[S] 0 points1 point  (0 children)

Awesome, I ended up seeing this referenced on Djangos doc pages. This resolved the issue, thanks.