RApache: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 26: Line 26:
like that.
like that.


Where was I? By now the toy examples should work, but sometimes it
By now the toy examples should work, but sometimes it
seemed like I needed to stop and start the web server to get it
seemed like I needed to stop and start the web server to get it
recognize changes I made to the R code. This may have been my
recognize changes I made to the R code. This may have been my
imagination. By the way, you can try to run
imagination, and sometimes the changes ''were'' recognized without
   /usr/sbin/apache2ctl -k stop
restarting the server. In any case, this can be done with
with your user account and it won't tell you that you
   sudo /usr/sbin/apache2ctl restart
fucked up because it has to be run as root.


Next problem I tried to get RApache to serve R-generated
Next problem I tried to get RApache to serve R-generated
Line 42: Line 41:
* Apply the patch using unix patch utility
* Apply the patch using unix patch utility
* R CMD INSTALL /path/to/GDD
* R CMD INSTALL /path/to/GDD
* and pray


Next problem was that GDD didn't know anything about fonts. None of the
Next problem was that GDD didn't know anything about fonts. None of the
fonts were coming up. The fix, according to GDD README, is to install
fonts were coming up. The fix, according to GDD README, is to install
ttmscorefont package. However, this doesn't exist for SuSE. Find  
ttmscorefont package. However, this doesn't exist for SuSE. Find  
msttcorefonts-2.0-1.spec and instructions to install it. This stupid
msttcorefonts-2.0-1.spec and instructions to install it. This packages
fucker requires another program called ttmkfdir to install, which
requires another program called ttmkfdir to install, which
of course I didn't have. So I had to get that. That one doesn't
of course I didn't have. So I had to get that. That one doesn't
know how to find another package called freetype-1.1, which I
know how to find another package called freetype-1.1, which I
Line 57: Line 55:
still complains it isn't there, so I have to comment
still complains it isn't there, so I have to comment
out the line in that file where it looks for ttmkfdir.
out the line in that file where it looks for ttmkfdir.
Finally it finishing ``building'' these fonts, whatever
Finally it finishes "building" these fonts, whatever
the hell that means,
that means,
and you can
and you can
install them into any directory, and finally you have to either
install them into any directory, and finally you have to either
Line 65: Line 63:
/usr/share/fonts/truetype/msttcorefonts/.
/usr/share/fonts/truetype/msttcorefonts/.


Now finally everything worked. What a bitch! Go have a beer.
Now finally everything worked. But it is really useful because now
I can use R to generate images for my web pages on the fly, and it
is really fast because the web server keeps an R process running
in the background so there is (1) no time needed for starting up
R and (2) no need to write images to disk.

Latest revision as of 12:44, 18 April 2007

This is a wonderful package that is very hard to install. It allows you to generate webpages and images from a continuously running R process and serve them through Apache without the overhead of starting and stopping R. It is totally sweet and super hard to install.

I needed many prerequisites. I installed the main RApache but it didn't tell me that I was missing the following packages:

 openldap2-devel
 gd-devel

Next it didn't tell me that I needed to change some lines in RApache.c. It used some retired macros. Two times the following line appears:

       APR_BRIGADE_FOREACH(bucket, MR_bbin) {

and it should be replaced with the following three lines:

       for(bucket = APR_BRIGADE_FIRST(MR_bbin);
           bucket != APR_BRIGADE_SENTINEL(MR_bbin);
           bucket = APR_BUCKET_NEXT(bucket)) {

Next there are problems with getting Apache to recognize it. You can follow the directions of how to change httpd.config, but Apache still couldn't find some R libraries. By the way, did I mention that you need to recompile R with the shared-libs options so that libR.so exists?

Anyway to get it to find those libraries you need to add the path to libR.so to /etc/ld.so.conf and run ldconfig. In my case the path I needed to add was /usr/local/lib64/R/lib/, and in general it should be $R_HOME/lib or something like that.

By now the toy examples should work, but sometimes it seemed like I needed to stop and start the web server to get it recognize changes I made to the R code. This may have been my imagination, and sometimes the changes were recognized without restarting the server. In any case, this can be done with

 sudo /usr/sbin/apache2ctl restart

Next problem I tried to get RApache to serve R-generated images. This is lots of fun. You can try the toy example in the RApache guide, but actually you will first need to install the patch for GDD:

  • Download the patch from the RApache webpage
  • Download the source for GDD
  • Apply the patch using unix patch utility
  • R CMD INSTALL /path/to/GDD

Next problem was that GDD didn't know anything about fonts. None of the fonts were coming up. The fix, according to GDD README, is to install ttmscorefont package. However, this doesn't exist for SuSE. Find msttcorefonts-2.0-1.spec and instructions to install it. This packages requires another program called ttmkfdir to install, which of course I didn't have. So I had to get that. That one doesn't know how to find another package called freetype-1.1, which I had to find using rpm -q freetype -l | grep libttf.so and | grep freetype.h and modify its Makefile. Then I had to move the binary into /usr/bin/ttmkfdir where the msttcorefont expects to find it. Then rpmbuild -bb msttcorefont-2.0-1.spec still complains it isn't there, so I have to comment out the line in that file where it looks for ttmkfdir. Finally it finishes "building" these fonts, whatever that means, and you can install them into any directory, and finally you have to either modify $R_LIBS/library/GDD/fonts/baseline.fonts to point to that directory, or else move your TrueType fonts into /usr/share/fonts/truetype/msttcorefonts/.

Now finally everything worked. But it is really useful because now I can use R to generate images for my web pages on the fly, and it is really fast because the web server keeps an R process running in the background so there is (1) no time needed for starting up R and (2) no need to write images to disk.