Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP不会执行LinuxBash_Php_Html_Bash_Virtual Machine - Fatal编程技术网

PHP不会执行LinuxBash

PHP不会执行LinuxBash,php,html,bash,virtual-machine,Php,Html,Bash,Virtual Machine,我正在尝试执行一个html函数,该函数将使用一个php文件运行一个LinuxBash脚本并关闭一组无头虚拟机。bash脚本将自行成功运行,但php文件没有执行该脚本。我确保为sudoers添加正确的行 #!/bin/bash VM_NAME='wintgt1' VBoxManage controlvm $VM_NAME poweroff VM_NAME='wintgt2' VBoxManage controlvm $VM_NAME poweroff VM_NAME='wintgt3' VBo

我正在尝试执行一个html函数,该函数将使用一个php文件运行一个LinuxBash脚本并关闭一组无头虚拟机。bash脚本将自行成功运行,但php文件没有执行该脚本。我确保为sudoers添加正确的行

#!/bin/bash
VM_NAME='wintgt1'
VBoxManage controlvm $VM_NAME poweroff

VM_NAME='wintgt2'
VBoxManage controlvm $VM_NAME poweroff

VM_NAME='wintgt3'
VBoxManage controlvm $VM_NAME poweroff
PHP


我还有其他脚本,它们的sudoers条目和php文件与这个脚本位于同一位置。但是,这个特定的php文件没有执行脚本。
谢谢

我想
VBoxManage
需要sudo用户吗?哪个
www-data
用户不是。看看你的另一个问题,同样适用。我能够解决我在上一个问题中遇到的问题。我对这个使用了相同的方法,但它不起作用。你能显示sudoers行www-data-ALL=(ALL:ALL)NOPASSWD:/etc/init.d/portstop.sh吗
<?php
shell_exec("sudo /etc/init.d/portstop.sh");
header("Location: http://192.168.1.21/mod/page/view.php?id=133&forceview$");
?>