I m trying to exec shell command within PHP script, but exec returns 126 code, which means "Command invoked cannot execute" (Permission problem or command is not an executable). But the funniest thing is that if I run the same php script under cli it works well. What's wrong with it?

Maybe there some issues with environment? Because when I run it under Apache it returns 127 code if I don't use absolute path to executable file (under cli it works well and return 0, even if I use just file name).The file is stored in /usr/local/bin folder.

UPDATE:

As asked in comment, I show example of my code, but there are nothing special.

This piece is working fine under cli, but doesn't work under apache ($retval will be equal to 127):

$output = array();
$retval = 0;
exec( "myexecutablefile /full/path/to/someotherfile.js", $output, $retval );
echo implode( PHP_EOL, $output );

This piece of code will return $retval = 126

$output = array();
$retval = 0;
exec( "/usr/local/bin/myexecutablefile /full/path/to/someotherfile.js", $output, $retval );
echo implode( PHP_EOL, $output );
Edit
Report