I want to start a virtual machine through PHP, but i've had no luck. Here's what i've got.
<?php
if(isset($_POST['btn_start'])){
echo shell_exec('whoami');
echo exec('virsh start winagain');
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Manage VPS</title>
</head>
<body>
<form method="POST" action="vps.php">
<input type="submit" name="btn_start" value="Start">
</form>
</body>
</html>
I get the error:
error: failed to connect to the hypervisor
error: no valid connection
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied
So i tried putting this line into my /etc/sudoers file
www-data ALL = NOPASSWD: /var/run/libvirt/libvirt-sock
But it has done nothing.
I'm running out of ideas now, please help.