运行 通过 SSH 包含在远程脚本中失败
Include in remote script fails when running it via SSH
我 运行 一个本地脚本,完成后对远程服务器上的脚本进行 exec 调用。
exec("ssh user@server.com \"php /full/path/to/script.php\"", $output, $return);
它向我显示了这个错误:
PHP Warning: require(../resources/vendor/autoload.php): failed to open stream: No such file or directory in /full/path/to/script.php on line 3
我已经尝试将所需的脚本加载到它的完整路径,但没有成功。有什么想法吗?
因为 PHP 将 CWD(当前工作目录)设置为您在 SSH 登录后所在的位置(大概是用户主文件夹)并且对 PHP 文件中包含的引用被解释为相对于慢性病。您应该将目录更改为项目的根目录:
exec("ssh user@server.com \"cd /full/path/to/; php script.php\"", $output, $return);
我 运行 一个本地脚本,完成后对远程服务器上的脚本进行 exec 调用。
exec("ssh user@server.com \"php /full/path/to/script.php\"", $output, $return);
它向我显示了这个错误:
PHP Warning: require(../resources/vendor/autoload.php): failed to open stream: No such file or directory in /full/path/to/script.php on line 3
我已经尝试将所需的脚本加载到它的完整路径,但没有成功。有什么想法吗?
因为 PHP 将 CWD(当前工作目录)设置为您在 SSH 登录后所在的位置(大概是用户主文件夹)并且对 PHP 文件中包含的引用被解释为相对于慢性病。您应该将目录更改为项目的根目录:
exec("ssh user@server.com \"cd /full/path/to/; php script.php\"", $output, $return);