PHP – Running scripts as root

Very simple situation and very simple fix.


echo shell_exec("sudo /usr/local/bin/");

Whether you are using apache of php-fpm, you need to grant your web server with sudo privilege. This can be done by adding the following line to /etc/sudoers file:

apache ALL=NOPASSWD: /usr/local/bin/

Done !

Majd Arbash

Leave a Reply