Assuming, that command in /opt/local/bin, change the command to
$cmd ='export PATH=$PATH:/opt/local/bin; myCommand 2>&1';
echo exec($cmd,$out);
To debug PHP exec command, Read this
For example:
For the PHP code:
$cmd = "gmake";
echo exec($cmd,$out);
There will be no output. In your web server error log, your will have :
sh: gmake: command not found
To fix this, we need to export the PATH of the gmake.Go to your terminal, find where your command is located, In this example:
$ which gmake
/opt/local/bin/gmake
So, modify you PHP code as following:
$cmd ='export PATH=$PATH:/opt/local/bin; gmake 2>&1';
echo exec($cmd,$out) ;
This will output, on your web page
gmake: *** No targets specified and no makefile found. Stop.