Submitted by g.carabetta on Thu, 04/20/2017 - 08:15 Pro Licensee
Hi, I need to set some env variables, but seems that the file
/etc/sysconfig/httpd
is not the correct place: I add in such file something like
ORACLE_BASE=/usr/lib/oracle
(or with export ) but the phpinfo() does not report it.
If I add inside the php script something like
putenv("TNS_ADMIN=/usr/lib/oracle/11.2/client64/network/admin");
all goes on.
May be there is a more virtual server specific site?
Thanks
Giulio Carabetta
Status:
Active
Comments
Submitted by g.carabetta on Thu, 04/20/2017 - 08:19 Pro Licensee Comment #1
Submitted by andreychek on Thu, 04/20/2017 - 08:45 Comment #2
Howdy -- can you describe how this particular environment variable would work, or what component/app it is that would need access to it?
PHP may not have access to environment variables set during the Apache startup though. If it's a PHP app that needs it we'd probably need to set that elsewhere.
Submitted by g.carabetta on Thu, 04/20/2017 - 09:01 Pro Licensee Comment #3
the env variables are needed for the OCI8 / Oracle instant client to correct find libs and other definition files (like tnsnames.ora).
A long time ago I found a workaround putting them in the /etc/init.d/httpd startup script, so the /etc/sysconfig/httpd seems to be the correct place, but it does not work, just like it is not exported to child processes.
I'm "just" looking for a method (the more correct) to add a pair name=value in the Environment section of the phpinfo() (oviously, called via http).
Submitted by andreychek on Thu, 04/20/2017 - 09:38 Comment #4
Hmm, you may want to see if this does what you're after:
https://httpd.apache.org/docs/2.4/mod/mod_env.html#setenv
Also, if you're trying to get ahold of a variable set from the shell, you may want to take a look at this here:
https://httpd.apache.org/docs/2.4/mod/mod_env.html#passenv
It's possible that you just need to use that in order for it to show in the phpinfo output.