On FreeBSD, I need NODE_ENV=production
and other systemwide environment variables to be set on startup, before nginx fires up.
Which is the right place i.e. file I do that?
On FreeBSD, I need NODE_ENV=production
and other systemwide environment variables to be set on startup, before nginx fires up.
Which is the right place i.e. file I do that?
Also, if you'd like to set some environment variables for an rc(8) service then you might also take a look at the ${name}_env
and ${name}_env_file
variables described in rc.subr(8). They allow you to set environment variables for services on FreeBSD in rc.conf(5), e.g.:
nginx_enable="YES"
nginx_env="NODE_ENV=production"
One option could be to add your environment variables to /etc/login.conf
in the setenv
capability, for example:
default:\
:passwd_format=sha512:\
:copyright=/etc/COPYRIGHT:\
:welcome=/etc/motd:\
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,NODE_ENV=production:\
...
From the login.conf man:
setenv list A comma-separated list of environment variables and values to which they are to be set.
If you modity the /etc/login.conf
file, don't forget to run:
cap_mkdb /etc/login.conf