【问题标题】:R script in phpphp中的R脚本
【发布时间】:2013-05-04 16:59:20
【问题描述】:

我正在终端中运行包含 Rscript 的 php 脚本。它工作正常并给出输出。但是如果我从网页调用相同的脚本,它不会提供任何输出。我也检查了文件夹权限。请帮我解决这个问题。

我的 php 脚本:

<?php
$abc=exec('Rscript dist/GS_R2html.R');
print "$abc\n";
?>

脚本:

a<-rnorm(1000)
library(R2HTML)
setwd('/var/www/test')
HTML.title("Data Summary", file="dist/gshtml.htm",append=F)
HTML(summary(a),file="dist/gshtml.htm",align="left")
HTML(matrix(a[1:100],nrow=10,byrow=T),file="dist/gshtml.htm",align="left")
HTML.title("Histogram", file="dist/gshtml.htm") 
jpeg("dist/plot2.jpg")
hist(a,col="red")
HTMLInsertGraph("dist/plot2.jpg",file="dist/gshtml.htm",Align="left")   
dev.off()

【问题讨论】:

  • 在您的通话中尝试 Rscript 的完整路径
  • 我也试过给出完整路径
  • 您是否在托管网页的同一台计算机的终端中尝试过 php 脚本?你有没有试过调用一个更简化的 R 脚本,只是为了看看 php -> R 连接是否有效?
  • 试试$abc=exec('Rscript 2&gt;&amp;1'); 见:stackoverflow.com/questions/818255/in-the-bash-shell-what-is-21

标签: php r


【解决方案1】:

这是由于缺少支持使用 R 和 Apache Web 服务器开发 Web 应用程序的 rApache。我按照http://rapache.net/manual.html 中提到的步骤在 Apache 中安装和配置 R。

【讨论】:

    猜你喜欢
    • 2017-09-09
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 2023-04-06
    相关资源
    最近更新 更多