Setting ENV variables on a vps

Hi, I need to set environment variables up on my vps for my node server to use. Anybody know if this is possible and if it’s secure? If this I possible how would I set the environment variables up? Thanks in advance.

1 Like

Yes it’s possible. It’s secure, although how secure it is depends on the particulars of your setup. (It’s more secure than, say, checking a configuration file in to GitHub.)

  1. SSH into your VPS and create a file named .env.
  2. Add your variables in the form export VARIABLENAME=VALUE (Note that there are no spaces on either side of the =. That’s important.)
  3. Type source .env to load the file into your shell.

Now your environment variables should be available to Node (and to other child processes).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.