Install werc Plan 9 with rc-httpd

werc can be installed on Plan 9 under rc-httpd with minimal alterations.

Patches are linked at the end of this file.

rc-httpd

Install rc-httpd.

The rc path must be changed to #!/bin/rc in the following files:

rc-httpd/handlers/cgi
rc-httpd/handlers/dir-index
rc-httpd/handlers/error
rc-httpd/handlers/form-test
rc-httpd/handlers/redirect
rc-httpd/handlers/serve-static
rc-httpd/handlers/static-or-cgi
rc-httpd/handlers/static-or-index
rc-httpd/handlers/web-test
rc-httpd/rc-httpd

rc-httpd/rc-httpd

Modify the following lines:

rc_httpd_dir = /path/to/rc-httpd
path = ( /bin $rc_httpd_dir/handlers )
cgi_path = ( /bin )

Optionally, remove the following line:

echo `{date} :: $SERVER_NAME :: $request >[1=2]

and add a function to enable slightly more verbose logging:

fn do_log {
    echo `{date} :: $SERVER_NAME :: $request :: $HTTP_USER_AGENT :: $1 :: $HTTP_REFERER >>$rc_httpd_dir/log >[2=1]
}

do_log takes as its argument the result of the current page request (e.g., 200, 404, 500, 503, etc.).

See the included patch below for suggestions on where to insert calls to do_log.

rc-httpd/handlers/dir-index

Modify the following line:

- if(! test -r $full_path -a -x $full_path) {
+ if(! test -r $full_path -x $full_path) {

listen

To launch rc-httpd with listen(8), create the file /bin/service/tcp80:

#!/bin/rc

/path/to/rc-httpd/rc-httpd >>[2]/path/to/rc-httpd/log

The log file must be writeable by the web server process.

werc

Unpack werc into your chosen directory: /usr/username/public_html/werc

Create a directory for your domain: /usr/username/public_html/werc/sites/domain.com

The rc path must be changed to #!/bin/rc in the following files:

werc/bin/aux/addwuser.rc
werc/bin/aux/bpst.rc
werc/bin/aux/gensitemaptxt.rc
werc/bin/aux/runtsts.rc
werc/bin/contrib/webserver.rc
werc/bin/fltr_cache.rc
werc/bin/werc.rc
werc/bin/werc_errlog_wrap.rc

The awk path must be changed to #!/bin/awk -f in the following files:

werc/bin/contrib/urldecode.awk
werc/bin/template.awk

Optionally, if perl has been installed on your system, correct the path in the following file:

werc/bin/contrib/markdown.pl

werc/etc/initrc

Modify the following lines:

#plan9port=$PLAN9
path=(/bin . ./bin ./bin/contrib)
formatter=(md2html.awk)
#formatter=(fltr_cache markdown.pl)

fltr_cache may be used if /tmp is writeable by the web server process.

werc/bin/werc.rc

Modify the following lines:

path=(. /bin ./bin)

werc/lib/default_master.tpl

Modify the following lines:

-     <h1 class="headerTitle"><a href="/">%($"siteTitle%) <span id="headerSubTitle">%($"siteSubTitle%)</span></a></h1>
+     <h1 class="headerTitle"><a href="/">%($"siteTitle%)
+ %   if(! ~ $#siteSubTitle 0) {
+         <span id="headerSubTitle">%($"siteSubTitle%)</span>
+ %   }
+     </a></h1>

werc/lib/headers.tpl

-     %($"extraHeaders%)
+ % echo $"extraHeaders

rc-httpd/select-handler

To configure werc for rc-httpd, create the file /path/to/rc-httpd/select-handler:

#!/bin/rc

cd /path/to/rc-httpd

if(~ $SERVER_NAME domain.com) {
    if(~ $location /_images/* /favicon.ico) {
        PATH_INFO = $location
        FS_ROOT = /usr/username/public_html/werc/sites/domain.com
        static-or-index
    }
    if not {
        PATH_INFO = $location
        FS_ROOT = /usr/username/public_html/werc/sites/domain.com
        static-or-cgi /usr/username/public_html/werc/bin/werc.rc
    }
}
if not error 503

Directories and filenames that begin with an _ do not appear in werc's default sidebar menu.

Patches

rc-httpd_plan9.diff

werc_plan9.diff


To post a comment you need to login first.