set_include_path在浏览器中使用时没有效果

I am using set_include_path() to add to the PHP search path so the server can find the gs executable. Things work as expected when I run the script from the command line (i.e., "php testpath.php") but, when I invoke the script from the browser on local-host (Mac OSX 10.11.5), it cannot find the executable. The testpath.php file is:

$path = '/usr/local/octave/3.8.0/bin';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
system("which gs");

Is there anything I need to do to get this script working so that it can find the gs executable from a browser invocation? Thanks!

In case anyone else had the same problem, I did the following to help convert find the gs executable:

system("PATH=/usr/local/octave/3.8.0/bin:\$PATH; /usr/local/bin/magick/convert $src $dst");