php shell_exec permission denied

shell_exec("touch /Users/Nerses/Downloads/ads.txt 2>&1")

I have a problem with the PHP exec(shel_exec) function. It says that I do not have permissions to execute the command.

How can I open these permissions?


Your PHP code is trying to access /Users/Nerses/Downloads/ads.txt, as you can see, that folder is owned by the user called "Nerses".

He is the only one (and root) who can access it (unless you change the permissions to that folder).

Normally, the user that executes shell_exec is called www-data, so give permissions to that user, or change the ones in that folder.

Other option is to execute

shell_exec('sudo -S YOUR COMMAND');

You can check out the user you use with the command


Need Your Help

What is the Linux equivalent to DOS pause?

linux bash shell

I have a Bash shell script in which I would like to pause execution until the user presses a key. In DOS, this is easily accomplished with the "pause" command. Is there a Linux equivalent I can use...

Redirect to login on session timeout in spring

javascript spring session redirect session-timeout

I have a multi-page web application, it uses iframe to handle the current page, and at the top I have the navigator.