Link to home
Start Free TrialLog in
Avatar of FWeston
FWeston

asked on

Set up sudo to alllow Apache / PHP to execute iptables commands

I need to run iptables commands by using PHP's 'system' function.  Currently no errors are returned when I try to do this, but I don't believe the command is being run either.  When I run the command on the console as root, it works, when trying to run it from PHP, it doesn't.

If I run 'whoami' from PHP it returns 'www-data'.  I tried to set up sudo so www-data can run iptables, but that's where I got lost...
Avatar of xDamox
xDamox
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi,

What is the exit status when you run the iptables command from PHP?? to display the exit status echo $?
ASKER CERTIFIED SOLUTION
Avatar of Liganic
Liganic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And after You configure sudo, don't forget to run from php
/usr/bin/sudo /sbin/iptables more options