dtdsbakn210537 2013-05-15 17:39
浏览 416

php shell_exec权限问题

I'm running as www-data and I'm trying to execute a shell script using shell_exec(/foobar/script/myscript.sh), but I'm getting the following error when the script attempts to write to a log file

cannot create /foobar/foo.log: Permission denied 

However, I don't run into any problems if I try running the script directly from the terminal. ie

$ sudo su www-data
$ /foobar/script/myscript.sh
$

Any idea what could be going on here?

I should also add that I added www-data to the group mybar and that this is what's showing up when I list the directory

drwxrwxr-x 3 mybar mybar  4096 May 14 14:18 foobar     # ls -l /


-rw-rw-r-- 1 mybar mybar 2824 May 15 09:57 foo.log     # ls -l /foobar
  • 写回答

2条回答 默认 最新

  • dougou7782 2013-05-15 17:50
    关注

    I think there can be two options:

    1. web-server and php-fpm are run under different users (by default that should not be). Try echo shell_exec('whoami');
    2. You have added www-data to mybar after php-fpm process had been started so it still "doesn't know" that it is (then I think restart of fpm should help).
    评论

报告相同问题?

悬赏问题

  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?