Black
Black

Reputation: 20212

Allow PHP to execute linux commands

I am dynamically creating files with laravel, I need to give them specific permissions by using chmod and change the user and group with chown.

I tried to enter the following lines to my /etc/sudoers by using visudo.

NOTE: Always use visudo otherwise you might corrupt the file.


www-data ALL=(ALL) NOPASSWD: chmod
www-data ALL=(ALL) NOPASSWD: chown

But I get syntax errors on these lines.

Upvotes: 1

Views: 90

Answers (1)

Black
Black

Reputation: 20212

You always have to use the full path to the binary:

www-data ALL=(ALL) NOPASSWD: /bin/chmod
www-data ALL=(ALL) NOPASSWD: /bin/chown

Upvotes: 2

Related Questions