Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can do this by exporting the variables in /etc/sysconfig/httpd and then using the PassEnv directive to make them available to Apache e.g.

In /etc/sysconfig/httpd

export JAVA_HOME=/path/to/java_home

In /etc/httpd/conf.d/envvars.conf (for example)

PassEnv JAVA_HOME

Then restart the httpd service.

share|improve this answer
    
Works perfectly, thanks! –  yegor256 Dec 19 '10 at 11:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.