Allow www-data to execute shell script
I have a shell script called boot.sh on an Ngnix server
I am trying to call it via PHP, but I don't think I have permissions.
How can I give www-data permission to run boot.sh - and only boot.sh
When trying sudo chown
or sudo chgrp
I am getting Operation Not Permitted
system("whoami");
to get the username of the webserver, I use www-data
in this example.
Edit your sudoers file and add the following. Where user
is the username it will be run under.
www-data ALL=(user) NOPASSWD: /path/to/program/or/script
Then use the following command in PHP.
system("sudo -u user /path/to/program/or/script");