exec() runs via command line but not web

前端 未结 4 2119
感情败类
感情败类 2021-01-25 20:31

I have a PHP script involving exec() that will run fine from the command line but not in a web context. The script is simply this:



        
相关标签:
4条回答
  • 2021-01-25 21:05

    Noticed you are writing to /home/jason. Note that apache will be the one running this command (i.e. www-data user if using Ubunut or Debian). Does the process have the correect rights to write to that folder?

    0 讨论(0)
  • 2021-01-25 21:06

    Your web server probably (correctly) doesn't have the appropriate permissions to write to a home directory.

    0 讨论(0)
  • 2021-01-25 21:13

    The web server runs as a different user, and that user does not have permission to write to your home directory.

    0 讨论(0)
  • 2021-01-25 21:18

    The other posters are correct to suggest the web server user doesn't have rights to write to your home directory. To see if they are right try modifying the code to write to /tmp/wee.txt. That should be world writable.

    Another possibility is that php can be configured to disable calling exec(). See http://www.cyberciti.biz/faq/linux-unix-apache-lighttpd-phpini-disable-functions/

    0 讨论(0)
提交回复
热议问题