Page 1 of 1

Problem on running exec() in Linux

Posted: Tue Jun 10, 2008 12:46 pm
by boonboon
Hi, I have some problem running exec() in php in linux

My scenario as below:

1) I have add JAVA_HOME in etc/profile
2) When I run the exec () in php, the error is
Error: JAVA_HOME is not defined correctly.
We cannot execute java
3) But when I run the same command in command line(root user), the script in the exec() can be run.
4) Found that the user right to run exec() in php is "apache"

Any idea what is the problem? My guess is the apache user didnt run the etc/profile for the environment setup, but I can't find other solutions.

Re: Problem on running exec() in Linux

Posted: Wed Jun 11, 2008 6:27 am
by Jenk
Simple workaround:

Code: Select all

exec('JAVA_HOME=\'/path/to/java/\' java blah');