user1400538
user1400538

Reputation: 865

How to provide required privilege for www-data user in php

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

Answers (1)

William Buttlicker
William Buttlicker

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

Related Questions