Linux/PHP: Let www-data run other commands (permission)

PHOTO EMBED

Sun Aug 28 2022 12:52:40 GMT+0000 (UTC)

Saved by @marcopinero #bash #php

*> sudo visudo

#find 'root ALL(...' and append this line below:

www-data ALL=NOPASSWD:/usr/local/bin/myscript.sh

#Save

*> sudo cp myscript.sh /usr/local/bin/
*> sudo chmod 777 /usr/local/bin/myscript.sh

#at php script:

<?php

$cmd = shell_exec("/usr/local/bin/myscript.sh params");
echo $cmd;

?>
content_copyCOPY