PHP:无法从 Web 执行命令行脚本



我在EC2上并使用ec2-user登录。我正在使用以下脚本来执行来自Apache的Python脚本。IT 从命令行工作,但不从 Web 工作,根本不打印任何输出。代码如下:

<?php
$command = escapeshellcmd('python3 /home/ec2-user/f1/f2/file.py');
$output = shell_exec($command);
echo $output;
?>

相同的脚本在命令行中工作正常

ssh 服务器并执行以下命令:

which python3

它将显示一些路径,因此请像这样更新命令:

path/to/python3 /home/ec2-user/f1/f2/file.py

最新更新