[R] HELP!! - PHP calling R to execute a r-code file (*.r)

Mike Marchywka marchywka at hotmail.com
Sat Dec 31 12:56:35 CET 2011












----------------------------------------
> Date: Fri, 30 Dec 2011 16:04:08 -0600
> From: xiuquan.wang at gmail.com
> To: r-help at r-project.org
> Subject: [R] HELP!! - PHP calling R to execute a r-code file (*.r)
>
> Hi,
>
> I have met a tough problem when using PHP to call R to generate some plots.
> I tested it okay in my personal computer with WinXP. But when I was trying
> to update to my server (Win2003 server), I found it did not work. Below is
> the details:

I've run into lots of problems like this. Generally first check the php error log file, I have noidea where it is on your machine, and see if you can get your script to dump output somewhere,possibly with absolute path so you know where to look for it LOL. Often the change in user creates unexpected problems with file permissions and libraries and paths. You need to checkthe specific direcories for permissions not just top level. 
I would also point out that there is Rapache available as well as Rserver. Curious if people are using R with any other unique situations server side. We have a java webserver which I use to invoke R via bash scripts and generate rathercomplicated files. These could take very long to generate but if you have flexible caching system,it can be easy to re use output files or even generate them ahead of time. Starting "R" or any otherprocess is not instantaneous and often image generation is quite time consuming. Thereare a lot of issues making it work well in a server setting in real time. Scale up has also been an issue. Apache threading or process model is quite expensive if you careabout performance. We were able to use "netty" front end and so far that has worked very well.PHP AFAIK is not thread safe however. 

>
> 1> r-code file (E:/mycode.r):
> ----------------------
> jpeg("E:/mytest.jpg")
> plot(1:10)
> dev.off()
> ----------------------
>
> 2> php code:
> -------------------
> exec("R CMD BATCH --vanilla --slave --no-timing E:/mycode.r && exit");
> -------------------
> 3> results:
> for WinXP: the image can be generated successfully.
> for Server(win2003): can not be generated.
>
> BTW, I have added a user "everyone" with full control permission to the E
> disk.
>
[[elided Hotmail spam]]
>
> Thanks.
>
>
> All the best,
> Xiuquan Wang
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
 		 	   		  


More information about the R-help mailing list