douyou2732 2011-10-16 15:49
浏览 15
已采纳

无法让php exec工作

I've been fighting with this for a few hours now, and I can't seem to work it out. tried exec(), shell_exec(), and system(). Nothing works. I have this:

exec("/usr/bin/php /var/www/vhosts/domain.com/httpdocs/shell/send.php >> /var/www/vhosts/domain.com/httpdocs/shell/paging.log &");

send.php simply has:

echo 'works';

But nothing shows up in the log. I've googled and read stuff on here, but I can't find anything to help.

I'm running php v.5.3.8. safe mode is on I'm pretty sure that is the path to php, but can't really find out how to find it, so I'm going on phpinfo().

exec('whoami'); does nothing. Is it suppose to show in the browser? or email you something? any ideas?

  • 写回答

3条回答 默认 最新

  • duanjianxu4288 2011-10-16 16:02
    关注

    According to PHP Manual for exec function:

    When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.

    Check http://php.net/manual/en/ini.sect.safe-mode.php#ini.safe-mode-exec-dir

    Also, be aware that the web server user must have permission to write in the log file.

    EDIT: To turn safe mode off, check not only php.ini file but also virtual hosts specific configurations in your web server, whether it is Apache, NginX or other. If you use Plesk, look in vhosts for httpd.include, and make sure that safe_mode is set to off there as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题