In Linux when I need to store a variable globally I use /etc/environment. What's the corresponding file in FreeBSD? I've seen this https://www.freebsd.org/doc/en_US.ISO8859-1/articles/new-users/your-working-environment.html but that didn't give me any clue.
In Linux we have /etc/environment for storing global variable. In FreeBSD?
freebsd;environment variables
The easiest option would be, as on Linux, to set the environment variables in the system's shell initialization files under /etc.  For sh-compatible login shells, this would be in /etc/profile, while for csh shells it would be /etc/csh.cshrc as explained in the article that you linked to.The login environment may also be set in /etc/login.conf.  This is not a shell script but the login class capability database, so it follows a strict format. You should read man login.conf before trying to modify it.To add two environment variables, VAR1 and VAR2, to this file, you choose what login class to modify and add:setenv=VAR1=value1,VAR2=value2:When done, run cap_mkdb /etc/login.conf as root as described in the manual.Notice that the default path is not set with setenv.