title: Conecting R with php
body: <p>I am trying to run a code of R in php localhost way; so I followed this example (<a href="https://www.r-bloggers.com/integrating-php-and-r/" rel="nofollow noreferrer">https://www.r-bloggers.com/integrating-php-and-r/</a>).</p>
  
  <pre><code>&lt;?php
  // poorman.php
  
  echo "&lt;form action='poorman.php' method='get'&gt;";
  echo "Number values to generate: &lt;input type='text' name='N' /&gt;";
  echo "&lt;input type='submit' /&gt;";
  echo "&lt;/form&gt;";
  
  if(isset($_GET['N']))
  {
    $N = $_GET['N'];
  
    // execute R script from shell
    // this will save a plot at temp.png to the filesystem
    exec("Rscript my_rscript.R $N");
  
    // return image tag
    $nocache = rand();
    echo("&lt;img src='temp.png?$nocache' /&gt;");
  }
  ?&gt;
  
  and the R script…
  
  # my_rscript.R
  
  args &lt;- commandArgs(TRUE)
  
  N &lt;- args[1]
  x &lt;- rnorm(N,0,1)
  
  png(filename="temp.png", width=500, height=500)
  hist(x, col="lightblue")
  dev.off()
  </code></pre>
  
  <p>I have both files in  /var/www/html/R folder; when I ran the php file goes perfectly but que I submit the number of "N" it did not show the same as the example web image.</p>
  
  <p>I also tried to run only to show a rnorm() distribution but I have the same results -> nothing.</p>
  
  <p>I think that my problems is in coneccting R with php so I tried installation Rapache (<a href="http://rapache.net/manual.html" rel="nofollow noreferrer">http://rapache.net/manual.html</a>) but when I reach 
  "sudo apt-get install apache2-prefork-dev apache2-mpm-prefork libapreq2-dev r-base-dev"
  I received the following message -> could not find package apache2-prefork-dev</p>
  
  <p>Any solutions?</p>
  
  <p>Thanks in advance</p>
  
  <p>George</p>