I am running a website on OSX server, that needs to execute pdftotext, which is installed in /usr/local/bin. However, there seems to be an issue with the command not being in the Apache path.
I first confirmed that I can execute shell scripts. <?php shell_exec('whoami'); ?> returns _www.
However, when I run the following :
$cmd = 'has pdftotext 2>&- || echo 1';
$out = shell_exec($cmd);
echo $out;
it returns "1" meaning it cannot access the command.
The same command run from terminal returns nothing (I can access the program without any issue).
When I run shell_exec('env'."2>&1") /usr/local/bin is indeed not in the path. Where do I set it for Apache2 on OSX Mountain Lion Server ?
UPDATE
See answer below