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 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥15 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)