在通过php执行shell脚本时传输文件到远程机器的问题


issue in transfer file to remote machine on executing shell script through php

我正在通过PHP执行脚本文件

shell_exec (sh script.sh)

script.sh是脚本文件的名称。这个脚本是用来传输文件说'abc'到远程机器。当我通过终端执行脚本文件

。/script.sh

它成功地将文件传输到远程机器,但当通过PHP执行相同的脚本文件时,它无法将文件传输到远程。

当您在shell中执行它时,您正在使用您的用户凭据。

当使用PHP脚本运行时,使用的是apache用户或组凭证。

确保apache可以运行您的脚本

从PHP脚本执行Bash脚本