werc-1.5.0-tweaks

Tweaks for the werc website builder created by the mad architect Uriel
Log | Files | Refs | README

plan-9-httpd.md (1712B)


      1 Setup werc with Plan 9's httpd
      2 ==============================
      3 
      4 
      5 There are two main options, you can use Russ Cox's magic to cgi translator
      6 (found in his contrib dir as cgi.c), or you can use the following script which
      7 while simpler, it also lacks some features at the moment.
      8 
      9 Thanks to soul9 for the original idea of wrapping werc in a shell script that
     10 would setup a cgi-like environment!
     11 
     12 
     13     #!/bin/rc
     14 
     15     SERVER_NAME=$2
     16     REQUEST_URI=`{echo $*(15)}
     17     REQUEST_URI=$REQUEST_URI(2)
     18     REQUEST_URI=/
     19     REQUEST_METHOD=$*(16)
     20     PLAN9=/
     21 
     22 
     23     echo 'HTTP/1.0 200 Ok
     24     Connection: close
     25     Server: werc/9.9.9' # This is whatever you like
     26 
     27 
     28     cd /usr/web/bin/
     29     rfork
     30     /bin/rc < ./werc.rc >[2]/usr/glenda/tmp/w/log # Use whatever location you like to log stderr, but make sure it is writable by none.
     31 
     32 Call this script werc-wrap, and put it in /rc/bin/ip/httpd/
     33 
     34 Then in your /sys/lib/httpd.rewrite  add a line like:
     35 
     36     /w @/magic/werc-wrap
     37 
     38 And this will run werc for all stuff under /w. Note that apparently httpd is
     39 incapable of internally remapping the root directory, so until a solution is
     40 found for this, you will have to keep your site in a sub-directory of the web
     41 server root.
     42 
     43 In your /lib/namespace.httpd you probably will want to add something along the
     44 following lines to bind the werc directory into the httpd's namespace:
     45 
     46     bind -b /usr/glenda/src/werc/ /usr/web/
     47     bind /usr/glenda/src/werc/bin/ /usr/web/magic/
     48 
     49 
     50 **Notes**: This is experimental and work in progress, there are a couple of issues
     51 with the werc code itself that might need fixing, in particular you will need
     52 to replace the '%($"extraHeaders%)' in lib/headers.tpl with '% echo
     53 $"extraHeaders' no clue why.