0

I have a ubuntu server deployed at digitalocean with gunicorn and nginx to host my django project. Now I want to save my secret key in an env. var. . I searched in the internet and I found that I have to modify a file called .bash_profile but I don't have this file in my home directory. What should I do?

Thx for your help and stay healthy!

4
  • Create the file with a text editor of your choice. Jun 25, 2020 at 9:18
  • Is this good practice?
    – Sven
    Jun 25, 2020 at 9:33
  • But if I create it .profile won't be read anymore?!
    – Sven
    Jun 25, 2020 at 9:36
  • bash reads both .profile and .bash_profile. Both are however not ideal locations to set environment variables for a service, see my answer. Jun 25, 2020 at 9:42

1 Answer 1

0

Create the file with a text editor of your choice.

~/.bash_profile would however not be an ideal location for this, because it's only read by bash. There are better places to set the environment variables. ~/.profile Is read by other shells as well, but those files are only read when the shell is called as a login shell. When you run an application as a service this is usually not the case.

Ideally you would configure an environment file in your service definition if your service is run by systemd, or set it in the startup script of your service if you are using another init system.

1
  • There is no way to answer that without knowing what you are running and how you are starting it. Jun 25, 2020 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .