2
I am trying to create an environment variable that will be accessed by a php script by the user that runs httpd (user: apache). It is set to /sbin/nologin
and therefore does not access .profile
, profile
, .bashrc
, etc....
I believe this variable must be carried globally by the OS (something like HOSTNAME
). But I’m not getting it. This variable is a json format string that contains the data for connection to databases, access credentials, etc. I don’t 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’d be grateful.
Only include variable declaration in apache start script, then it already goes up declaring variable (
/etc/init.d/apache
is the first place that comes to mind, but in systemd times will know where it can be). That being said, if you need to change any information on that data you will also have to restart apache (even if he had one . profile that would be true), so why not declare right inside PHP?– nunks