libpng16.16.dylib 从 PHP 文件使用 “exec” 执行 PHP CLI 时出现加载错误


libpng16.16.dylib load error when executing PHP CLI with "exec" from PHP file

我在Mac OS X Yosemite上运行PHP 5.5。 PHP 5.5 与 Homebrew 一起安装。

我有一个必须异步执行(从 CLI)的.php脚本。 如果我从终端执行它,它可以正常工作。 但是,如果我在我的 PHP 应用程序中执行它,它不起作用。

启动脚本(由 Apache 运行)的代码为:

// 1.- Alter path so that Homebrew PHP is launched
putenv("PATH=/usr/local/bin:" . getenv("PATH"));
// 2.- Exec PHP script in background
exec("php /path/to/my/file/script.php > /dev/null &");

我收到以下错误:

Library not loaded: /usr/local/lib/libpng16.16.dylib
  Referenced from: /usr/local/bin/php
  Reason: no suitable image found.  Did find:
    /usr/local/lib/libpng16.16.dylib: stat() failed with errno=13
    /usr/local/lib/libpng16.16.dylib: stat() failed with errno=13

有什么线索吗?

我已经尝试了 dyld 中的解决方案:库未加载:/usr/local/lib/libpng16.16.dylib 与任何与 php 相关的内容都没有运气

stat() failed with errno=13表示存在权限错误。.dylib文件应该有读取权限,它所包含的目录也应该设置可执行(x)位。(我认为读取 [ r] 位也应该设置,但我不是 100% 确定。