PHP执行root权限命令报错:

Failed to restart network.service: Interactive authentication required. See system logs and 'systemctl status network.service' for details.

 

linux下:

编辑

/etc/sudoers  文件

//添加执行php的用户
#lighttpd    ALL=(ALL)       NOPASSWD:ALL   #web(php执行) 用户
apache  ALL=(ALL)       NOPASSWD:ALL
#nginx   ALL=(ALL)       NOPASSWD:ALL

PHP代码执行
$parameter = '/usr/bin/sudo test.sh';
$res = exec($parameter,$arr);

system("");///