问题
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
回答1:
Call putenv before exec:
putenv('PATH=/usr/ant/bin');
回答2:
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.
来源:https://stackoverflow.com/questions/10835923/how-to-set-path-for-php-exec-or-shell-exec