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...
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And after You configure sudo, don't forget to run from php
/usr/bin/sudo /sbin/iptables more options
/usr/bin/sudo /sbin/iptables more options
What is the exit status when you run the iptables command from PHP?? to display the exit status echo $?