How to run PHP exec() as root?

Don’t do it! You will leave yourself wide open to all sorts of malicious hackery.

Have a look at the “sudo” documentation.

You should be able to set up all the commands you need as “sudo”able scripts.
It is much better to write specific scripts with limited functions than to expose
the underlying priviledged command.

As in:

exec ('sudo getIpTables.ksh')

Leave a Comment