php shell_exec permission denied

℡╲_俬逩灬. 提交于 2019-12-23 15:51:03

问题


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?


回答1:


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

shell_exec('whoami');


来源:https://stackoverflow.com/questions/32066800/php-shell-exec-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!