Persist environment variable for a Rails app on Digital Ocean

左心房为你撑大大i 提交于 2021-01-27 12:37:55

问题


How can I persist environment variables for my Rails app hosted on Digital Ocean?

Locally I run a bash script with commands like, export SERVICE_USERNAME='somekey'.

But when I try to manually run export SERVICE_USERNAME='somekey', while ssh-ing onto the Ubuntu server, they only last for the session... which is not helpful for my app.

How can I persist environment variables on Digital Ocean? Is there a simple way?


回答1:


You can either set your environment variables to the user (in the ~/.profile or ~./pam_environment files of the user) or system wide (in the /etc/environment file)

You can find more info on this Ubuntu documentation.

EDIT;

You could have your script to do this:

sudo echo 'export SERVICE_USERNAME="somekey"' >> /etc/environment


来源:https://stackoverflow.com/questions/42615522/persist-environment-variable-for-a-rails-app-on-digital-ocean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!