gpt4 book ai didi

从浏览器而非 CLI 调用时 PHP exec 失败

转载 作者:可可西里 更新时间:2023-11-01 00:34:20 25 4
gpt4 key购买 nike

我有一个简单的 PHP 脚本:

exec('git pull origin master', $shell_output, $output);
print_r($shell_output);
print_r($output)

当我通过 CLI php git.php 调用它时,它工作正常。我得到了预期的输出,返回值为 0。当我通过网络浏览器访问该页面时,它失败了,返回值为 1。

我已将文件权限设置为 777,并确保 php.ini 不会阻止 exec() 函数。

最佳答案

CLI 使用当前登录用户(您)的凭据运行,它很可能与 Web 服务器进程使用的不同。执行 exec('whoami') 等来验证。

关于从浏览器而非 CLI 调用时 PHP exec 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13097550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com