I have set the PATH to run ant and it is working on putty but on php exec it is returning sh ant command not found i have tried to set PATH by export PATH=/usr/ant/bin
Asked
Active
Viewed 8,165 times
2 Answers
6
Call putenv before exec:
putenv('PATH=/usr/ant/bin');

Alexander Mikhalchenko
- 4,525
- 3
- 32
- 56

cuixiping
- 24,167
- 8
- 82
- 93
0
Environment variables are set in the context of a user session. If you want to set the variable for the PHP user you should check what user apache runs under (typically apache), and add
export PATH=/usr/ant/bin
to
/home/apache/.bashrc
So that the path is set for every session the user apache
starts.

KeatsKelleher
- 10,015
- 4
- 45
- 52
-
-
yeah, that should be fine...you'll want to use `useradd` just make sure you apache user is in fact called 'apache'. what version of linux are you running? http://linux.die.net/man/8/adduser – KeatsKelleher May 31 '12 at 15:47