调用php exec()时未加载共享库

I am triggering an executable using php

$commstr = '/abs/path/to/binary > status.txt &';
echo "Running command: ".$commstr."
";
shell_exec($commstr);

PHP exec() or for that matter system() or shell_exec() works fine because status.txt gets written to, but cat status.txt says error while loading shared libraries: libQtCore.so.4: cannot open shared object file: No such file or directory. This means the binary doesn't get executed

I tried changing my php code to the following without any luck

$commstr = 'export LD_LIBRARY_PATH=/path/to/lib ; /abs/path/to/binary > status.txt &';

The binary is readable by user apache and so are the libraries.

Try running the command as sudo.

for example

$commstr = 'sudo export LD_LIBRARY_PATH=/path/to/lib ; /abs/path/to/binary > status.txt &';