It's CentOS 5. I created /etc/profile.d/java.sh
file where I set and export JAVA_HOME
. Everything works fine in terminal.
When I'm trying to get this environment variable from PHP under Apache I get the following, after using shell_exec("env")
:
TERM=xterm-color
_=/bin/env
PWD=/home/...
LANG=C
SHLVL=3
Not even a sign of JAVA_HOME
. Where should I declare it to make visible for apache?
You can do this by exporting the variables in
/etc/sysconfig/httpd
and then using thePassEnv
directive to make them available to Apache e.g.In /etc/sysconfig/httpd
In
/etc/httpd/conf.d/envvars.conf
(for example)PassEnv JAVA_HOME
Then restart the httpd service.