By lcbacellar
I am having some troubles to configure a Django app (using virtualenv) with Postgres, Nginx, and Gunicorn on Ubuntu 16.04.
Everything worked fine until I started setting some environment variables for some Django configuration variables. Ex.: SECRET_KEY = os.environ[‘DJANGO_SECRET_KEY’].
I have tried a lot of options like setting variables on virtualenv’s activate file, setting variables on ubuntu, and on gunicorn.service file but nothing is working.
Does anyone know how to work on this issue? How to set the environment variables?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @kameruchi:
Hi! Instead of adding the variables to the gunicorn command line, you could load them through a file: <on gunicorn.service> [Service] … EnvironmentFile=/path_to_/some_file_with_secrets … This should make the trick. (dont forget to create the file with those secrets)
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.