简体   繁体   English

如何为Django项目存储除gunicorn.service内的环境变量?

[英]How to store env variables other than inside gunicorn.service for a Django project?

I tried putting all my environment variables for my Django project inside ~/.bash_profile and then use it in gunicorn.service with EnvironmentFile=/home/user/.bas... but with no luck. 我尝试将我的Django项目的所有环境变量都放入~/.bash_profile ,然后在带有EnvironmentFile=/home/user/.bas... gunicorn.service中使用它,但是没有运气。 Eventually I had to put everything in ExecStart with -e in front of every variable, also with SECRET_KEY and everything in plain text. 最终,我必须将所有内容放在ExecStart ,将-e放在每个变量的前面,还必须将SECRET_KEY和所有内容都以纯文本格式放置。 Is it safe, is it possible to access this externally or how else could I do this? 安全吗?是否可以从外部访问它?或者我还能怎么做?

您可以使用.env文件和python-dotenv包来处理变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Centos 8 上部署 Django 项目,使用 Gunicorn,Nginx(Gunicorn.service 问题) - Deploying Django project on Centos 8, using Gunicorn, Nginx (Gunicorn.service problem) 无法启动 gunicorn.service:未找到单位 gunicorn.service。 乌本托 18.04 - Failed to start gunicorn.service: Unit gunicorn.service not found. Ubunto 18.04 Gunicorn.service 无法读取 Python3.6 库 - Gunicorn.service unable to read Python3.6 library 由于导入模块错误,无法启动gunicorn.service - Unable to start gunicorn.service due to import module error 无法启动 gunicorn.service:gunicorn.socket 的作业失败。 乌本托 18.04 - Failed to start gunicorn.service: Job for gunicorn.socket failed . Ubunto 18.04 在虚拟环境上运行django的gunicorn - gunicorn running django on virtual env Django:如何使用 gunicorn 在正在运行的环境中运行 python 脚本 - Django: How to run python scripts on a running env with gunicorn 如何在Django后台运行项目,使用gunicorn? - How to run background the project Django, use gunicorn? 是否应该在 systemd 服务单元配置中为 gunicorn 设置 PATH 和 VIRTUAL_ENV 环境变量来为 Flask 应用程序提供服务? - Should PATH and VIRTUAL_ENV environment variables be set in systemd service unit config for gunicorn to serve a Flask app? 如果 Django 项目从 Github 部署到 AWS,如何从“.env”文件访问环境变量? - How are environment variables accessed from ".env" file if Django project deployed to AWS from Github?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM