PHP Shell ffmpeg 的执行未读取 Bash 配置文件

PHP Shell Excution of ffmpeg Not Reading Bash Profile

我知道这是一个奇怪的问题并且可能非常具体,但我最近在共享主机服务上安装了 ffmpeg。虽然我可以从 SSH 控制台执行所有任务,但在 PHP 中进行完全相同的调用时,我收到此错误。

error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory

它在 PuTTY 中做了同样的事情,直到我用这一行更新了 ~/.bash_profile

export LD_LIBRARY_PATH=/home/searay330/ffmpeg/lib

PHP 没有使用 ~/.bash_profile,还是有其他文件需要更新?非常感谢有关此主题的任何信息,谢谢。

您需要将其放在 .bashrc 中。 .bash_profile 仅在使用交互式登录-shell 时读取,而 .bashrc 在 Bash 交互式启动但不是登录-shell 时读取。有关详细信息,请参阅 here。所以,你不能真正使用 .bashrc.bash_profile。在调用 shell_exec().

之前,您需要在 PHP 中设置环境变量
<?php
putenv('LD_LIBRARY_PATH=/home/searay330/ffmpeg/lib');
shell_exec('...');