Quote:
Originally Posted by jeethapj
Ok sir.I have tried as "apache ALL = NOPASSWD: /etc/init.d/network restart",
"httpd ALL = NOPASSWD: /etc/init.d/network restart"..
When I checked "whoami" it is giving the result as "asterisk"..Then I tried also
"asterisk ALL = NOPASSWD: /etc/init.d/network restart"..
Then I run the script
<? php
System('sudo /etc/init.d/network restart',$result);
echo "$result";
?>
Then nothing is happening and it is displaying the result 1.
Also when I tried
<? php
System('service network restart',$result);
echo "$result";
?>
It is returning the result as 0 and also displaying
Shutting down interface eth0: [FAILED] Shutting down loopback interface: [FAILED] Bringing up loopback interface: [FAILED] Bringing up interface eth0: [FAILED]
|
here are the step which you need to follow;
1) Comment a option into of "Default requiretty" using visudo
Code:
cat /etc/sudoers | egrep "requiretty|apache"
#Defaults requiretty
apache ALL=NOPASSWD: /etc/init.d/network restart
2) your php code
Code:
<?php
system('sudo /etc/init.d/network restart',$result);
echo "$result";
?>
it must work.