Reading ROOT Files via Apache Web Server


By adding one ROOT specific module to your Apache web server you can distribute ROOT files to any ROOT user. No need anymore for ftp'ing files containing (out of date) histograms or other objects. Your latest up-to-date results are always accessable to all your colleagues.

How to access ROOT files via a web server. Simple, just create a TWebFile object instead of a TFile object with a standard URL as file name. For example:

root [0] TWebFile f("http://root.cern.ch/~rdm/hsimple.root")
root [1] f.ls()
TWebFile** http://root.cern.ch/~rdm/hsimple.root
TWebFile* http://root.cern.ch/~rdm/hsimple.root
KEY: TH1F hpx;1 This is the px distribution
KEY: TH2F hpxpy;1 py vs px
KEY: TProfile hprof;1 Profile of pz versus px
KEY: TNtuple ntuple;1 Demo ntuple
root [2] hpx.Draw()

Since TWebFile inherits from TFile all TFile operations work as expected. However, due to the nature of a web server a TWebFile is a readonly file. A TWebFile is ideally suited to read relatively small objects (like histograms or other data analysis results). Although possible, you don't want to analyse large TTree's via a TWebFile.

Here follows a step-by-step recipe for making your Apache 1.1 or 1.2 web server ROOT aware:

  1. Go to your Apache source directory and add the file mod_root.c (or mod_root133.c when your Apache server is > 1.2 (rename the file to mod_root.c)).
  2. Add to the end of the Configuration file the line:
    Module root_module mod_root.o
  3. Run the Configure script
  4. Type make
  5. Copy the new httpd to its expected place
  6. Go to the conf directory and add at the end of the srm.conf file the line:
    AddHandler root-action root
  7. Restart the httpd server

If you have Apache 1.3 you can also add modules without recompiling the server source. Do the following to compile and add the file mod_root133.c:

  1. gcc -c -I/usr/include/apache/ -DSHARED_MODULE -DEAPI mod_root133.c
  2. ld -shared -o mod_root.so mod_root133.o
  3. cp mod_root.so /usr/lib/apache/
  4. Configure Apache
  5. Restart the httpd daemon

That's all.


Rene Brun, Fons Rademakers
Last update 8/3/2001 by FR