I am trying to execute a PHP file that interacts with Rserve on a LAMP system. The PHP file is located in the public_html directory on the server. Rserve is installed and running in Rserve's default directory within R (/usr/lib64/R/library/Rserve).
Is there a particular folder the PHP files need to be in for a proper connection to Rserve? Do I need to use a remote connection when both Rserve and the PHP files are on the same server?
The PHP file returns this error: No path specified.Invalid response from server.Connect FAILED
Sample PHP-Rserve test file:
<?php
require_once 'simple.php';
$s = Rserve_connect();
if ($s == FALSE) {
echo "Connect FAILED";
} else {
print_r (Rserve_eval($s, "list(str=R.version.string,foo=1:10,bar=1:5/2,logic=c(TRUE,FALSE,NA))"));
echo "<p/>";
print_r (Rserve_eval($s, "{x=rnorm(10); y=x+rnorm(10)/2; lm(y~x)}"));
Rserve_close($s);
}
ob_end_flush();
?>
Telnet result:
#telnet 127.0.0.1 6311
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Rsrv0103QAP1
Process Result:
# ps ax|grep Rserve
14028 ? Ss 0:00 /usr/lib64/R/bin/Rserve
15264 pts/3 S+ 0:00 grep Rserve
i think you would need to pass host and port params to connect. example