Reputation: 865
I am trying to execute a shell script which will copy certain folders and files from one location to another.
But I am struggling with a very basic problem - ie; I cannot copy folders or files when I call this script from php. Whereas the same script works perfect from terminal. Is it because that, from terminal when I execute this script, the user has has enough privileges to copy/create files/folders , where as when the script is called from php, the user does not have enough privileges?
For php, shell_exec('whoami');
says the user is www-data
What should I do, in order that, I have enough privileges to do the create and copy operations from php user www-data
Any help is much appreciated.
Upvotes: 0
Views: 412
Reputation: 6000
Add this:
username ALL=NOPASSWD: /path/to/script
in your sudoers file, In /etc/sudoers
, you can also use visudo
command to edit that file.
Upvotes: 1