Results 1 to 5 of 5
hi
how i can run this command (service iptables restart) from php code?
i try to use exec function, this the code
<?php
$output=shell_exec('service iptables restart');
echo "<pre>$output</pre>";
?>
but ...
- 06-25-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 38
php problem
hi
how i can run this command (service iptables restart) from php code?
i try to use exec function, this the code
<?php
$output=shell_exec('service iptables restart');
echo "<pre>$output</pre>";
?>
but it doesn't exec this command but another simple commands can run.
please help me.
- 06-25-2008 #2
You need root to execute that command...
I suggest you configure it in sudo and execute it trough sudo
- 06-25-2008 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 38
how i can configure it from sudo?
- 06-25-2008 #4
Execute as root:
enter the following lines:Code:visudo
Save it... You must be familiar with Vim text editor.. visudo uses the same methods of editing...Code:Cmnd_Alias RES=/etc/init.d/iptables restart apache ALL=NOPASSWD: RES
Then you will be able to use:
Code:$output=shell_exec('/usr/bin/sudo /etc/init.d/iptables restart');
- 06-25-2008 #5Just Joined!
- Join Date
- Apr 2008
- Posts
- 38
i did what you say but i faild.
can you give me another solution?


Reply With Quote