Problem on running exec() in Linux

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
boonboon
Forum Newbie
Posts: 1
Joined: Tue Jun 10, 2008 12:37 pm

Problem on running exec() in Linux

Post 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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: Problem on running exec() in Linux

Post by Jenk »

Simple workaround:

Code: Select all

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