I'm trying to create an environment variable that will be accessed by a php script by the user running httpd (user: apache). It is defined as /sbin/nologin
and therefore does not access .profile
, profile
, .bashrc
, etc ...
I assume that this variable has to be loaded globally by the OS (something like HOSTNAME
). But I can not. This variable is a string in json format that contains the data for connecting to databases, access credentials, and so on. I do not know if this is the safest way to do this, but intuitively I think so. See an ex:
linux environment:
MY_VAR_DATA='{"driver":"mysql","host":"ip_host_remoto","user":"nome_do_usuario","password":"senha_do_usuario"}'
export MY_VAR_DATA
in php:
$connData = json_decode(getenv('MY_VAR_DATA'), true);
If anyone can help me, I'm grateful.