我正在尝试从浏览器运行 git pull 的 php 脚本,但我得到“sh:连接到主机 git.assembla.com 端口 22:权限被拒绝”
我的 php 脚本:
<?php
$output=array();
$returnVar=0;
chdir("/var/www/html");
exec('git pull git@git.assembla.com:andrewadel.git master 2>&1', $output , $returnVar);
// exec('pwd', $output , $returnVar);
echo "<pre>\n";
echo "return status: $returnVar\n\n";
print_r($output);
echo "</pre>\n";
当我手动将脚本作为“apache”运行时,一切都很好
bash-4.1$ whoami
apache
bash-4.1$ php gitsync.php
<pre>
return status: 0
Array
(
[0] => From git.assembla.com:andrewadel
[1] => * branch master -> FETCH_HEAD
[2] => Already up-to-date.
)
</pre>
当我从浏览器运行它时,它失败了
http://103.7.164.33/gitsync.php?111
return status: 1
Array
(
[0] => ssh: connect to host git.assembla.com port 22: Permission denied
[1] => fatal: The remote end hung up unexpectedly
)
谢谢