Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I designed a web page that lets user define some criteria using drop-boxes etc. and php collects the relevant data from the database according to that criteria.

What I intend to do is modeling a least squares trend line over that data using R and displaying coefficients and plot etc.

But I'm unable to run R, though it's installed in the server and works as expected when invoked within the server. I guess there are some security issues.

Can anyone lead me to a solution. My hosting company says it's impossible to run a exec() command to invoke R within PHP because of security reasons.

Thanks so much, jan

share|improve this question

migrated from stackoverflow.com Jun 29 '10 at 19:27

This question came from our site for professional and enthusiast programmers.

1  
Sounds like your hosting company sucks. –  Rook Jun 29 '10 at 15:48

4 Answers 4

I wrote a trending class in pure PHP as part of PHPExcel, to provides the functions for calculating coefficients and plot. It should provide everything that R can provide. As an alternative to running R itself, you can find it on the PHPExcel site at codeplex. If you can't find an exec() solution, you're welcome to pillage that code to provide a pure PHP solution, though I'd appreciate any feedback/bugfixes/etc

share|improve this answer
1  
Actually I'm thinking of developing the project so that it is capable of doing more complex calculations, like neural-network estimations. Besides, I've written a ready-to-use model in R. But your project seems like my next stop if getting R to work fails, at least as a start. Indeed, it looks like excellent for other but similar purposes! Good work & thanks! –  Jan Sahin Jun 29 '10 at 10:02
    
Only suggested as a fallback alternative. R is a far better and more efficient tool for the job if you can get it working with PHP –  Mark Baker Jun 29 '10 at 10:22

There is a post about configuring R right here on SO. Not all the answers are using exec().

share|improve this answer
    
I've seen that post but in that post Brendon says he found better answers in other forums. Actually, I was trying to ask this question directly to Brandon but I found myself here and edited the question as a general question :$ –  Jan Sahin Jun 29 '10 at 9:52

I was looking for an answer to your question also, and by now all that I have read said that you will need more privileges on your server (which you won't get on shared hosting).

Potentially going do a virtual dedicated server would work for you, but I don't know yet of someone saying that he did it and that it works.

I wrote about projects to get R online on my blog here (like ggplot2 web interface and R-node), If you find good solutions, please let me (us) know.

Best,

Tal

share|improve this answer
    
Hi Tal, In fact, this man (Matthew Jockers) here seems to achieve exactly what I wanted. I followed his instructions step by step with no luck, but it may be useful for you and your blog: stanford.edu/~mjockers/cgi-bin/drupal/node/25 I guess, it's mostly about privileges on the server, as you said. I have a virtual dedicated server in my hands but and I'm dealing with my provider ATM. Thanks, jan –  Jan Sahin Jun 29 '10 at 22:42
    
Thank you for the link Jan - very interesting ! Best, Tal –  Tal Galili Jun 30 '10 at 7:56

You may check this site: http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces
On the other hand, some time ago I was making something similar and I used a named pipe through which PHP was sending commands to a constantly running R instance, which was then putting its output directly to the database. In this solution the pipe served as a queue, so it could survive multiple clients at one time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.