我有一个简单的脚本,它必须重新启动服务器上的进程:exec("systemctl stop listener.service");
这个脚本不能从浏览器执行,我不知道他有什么问题.因为如果我运行:exec("systemctl status listener.service | grep Active");
它的作品!
我试探着:
$command = "systemctl stop listener.service";
system($command);
shell_exec($command);
exec($command);
$command = "sudo systemctl stop listener.service";
system($command);
shell_exec($command);
exec($command);
字符串
我已经添加了“%www-data ALL=(ALL:ALL)ALL”的想法visudo.浏览器显示0错误(错误报告是启用的,我试图犯错误,特别是-它显示在浏览器,但这个脚本显示0错误.我已经关闭了所有的标签,因为它需要.
什么都不管用。
我甚至试图从php运行python脚本-它仍然不工作。如果我试图从服务器控制台运行脚本-它的工作,即使我不给根访问脚本。如果我试图从服务器运行脚本“php -a”控制台-它的工作,但它不从浏览器工作。Idk什么是错的这个脚本.
1条答案
按热度按时间svmlkihl1#
最后,我必须使用“sudo visudo”添加指令:
字符串
现在它起作用了。感谢@Barmar