Updated 2012-04-30 00:27:31 by RLE

Some excellent discussion exists at Wikit Problems Which is a good place to find wikit CGI solutions!

06feb03 jcw - I've set up a page with detailed comments on how to get CGI working. It's aimed at being able to run starkits in general, but it'll probably also be of use for wikit:
    http://www.equi4.com/259

LES often wonders if there is any documentation on the impact of running Tclkit and Metakit under CGI on the server's overall performance.

SEH -- If you want to run Wikit under CGI using Windows, replace tclkit with tclkitsh when reading the above-referenced page.

Another useful page is Wikit configuration, which lists the different environment variables Wikit understands.

Note: On Windows, when running under CGI, you will want to download the console version of Tclkit (tclkit-win32-sh.exe.gz), not the GUI version, otherwise the process hangs after rendering the page (AKG).

One useful future topic to cover here would be how to configure a web site so that a Wikit is read only for most people, but updatable by someone entering a login and password.

Obsolete info follows, this page needs to be fixed...

WiKit and TclKit were designed to run out-of-the-box, with no installation or configuration whatsoever. The installation is just like for local use, but you will need to work around the limited permissions provided by some web servers.

There are two issues:

  1. Where to put the WiKit file and how to let it find TclKit.
  2. Accessing and altering the database embedded in WiKit.

mh: Accessing wikit works fine from Apache if done carefully and slowly, but if (apparently) two copies try to run at the same time, an error 500 is returned and this shows up in the apache log:
  [error] (26)Text file busy: exec of /ap/htdocs/wikit.dvp failed
  [error] [...] Premature end of script headers: /ap/htdocs/wikit.dvp

Any ideas?

If your server does not let you run scripts under your own ID:

  • Make sure the WiKit file is executable and writable by all: chmod a+rwx wikit.tkd
  • Make sure WiKit is allowed to create a lockfile next to it (called wikit.lock)

If your server requires CGI scripts to end in ".cgi":

  • Just rename "wikit.tkd" to wikit.cgi, since WiKit will work under any name

If your script doesn't work because it can't find TclKit:

  • You'll have to write a small wrapper. Here's a "wikit.cgi" script which worked for me:
        #!/bin/sh
        exec /home/jcw/bin/tclkit /home/jcw/wikit/wikit.tkd

If you're wondering how WiKit can act as both a CGI script and as a Tk GUI app: what it does is look for an environment variable called "SCRIPT_NAME". If present, it proceeds as a CGI process, else it turns itself into a Tk GUI application.

DGR - I'm am not familiar with CGI usage. I would like to run WiKit on my own windoze pc under Netscape. I think I need to learn about ServerBasics. I do have WiKit running under TclKit and it works great.

Anyone know why a Linux box would generate:
 Mon May 28 15:15:48 2001] [error] [client 192.168.1.71] Premature end of script headers: /export/home/gershom/public_html/cgi-bin/wikit.cgi
 application-specific initialization failed: /usr/tmp/tclkit not owned by
 /usr/tmp/tclkit not owned by
    while executing
 "error "$temp not owned by $user""
    (in namespace eval "::vfs" script line 30)
    invoked from within
 "namespace eval ::vfs {
    variable debug      0
    if {[info exists env(VFS_DEBUG)]} {
        set debug $env(VFS_DEBUG)
    }

    variable fstab
    variable ..."
    ("uplevel" body line 58)
    invoked from within
 "uplevel #0 $s"
    (procedure "tclInit" line 68)
    invoked from within
 "tclInit"
 [Mon May 28 15:17:50 2001] [error] [client 192.168.1.71] Premature end of script headers: /export/home/gershom/public_html/cgi-bin/wikit.cgi

/usr/tmp is a link to /var/tmp. And my UID does own /var/tmp/tclkit. I used the script above, and other cgi scripts work in that directory. It runs in local mode.

JCW: Oops, this is my fault... I accidentally released a build of TclKit (8.4-22) which has a problem with shared-lib loading. Please update to a newer build of TclKit (see [1]).

lh That was it. Thanks! (Do we need to cut out some/all of the above?)

Short instructions for running a CGI Wikit on linux/apache.

1. Download the Wikit [2].

2. Download the proper TclKit [3] 8.4-23 seems the most current as of 9 Sep 02.

3. Put both into your $HOME/public_html/cgi-bin directory; or wherever the "UserDir" puts personal web pages. Mine "UserDir" is defined in srm.conf.

4. Change the names, tclkit.bin to tclkit, wikit.bin to wikit.tkd.

5. See the above note about the wikit.cgi shell wrapper.

6. Set the permissions to ???

7. Make sure your webserver can serve cgi pages. This includes the "ExecCGI" in access.conf

8. Restart the web server.

9. Make sure you have a web server running. ps -ef | grep httpd should show several lines of httpd.

10. View the page as http://{server}:{port}/~{username}/cgi-bin/wikit.cgi

11. If there are problems, read the error_log file. Mine is in /etc/httpd/logs.

12. Deeper Apache information [4].

If http://server:port/dir/cgi-bin/wikit.cgi brings up a page where none of the links appear to work, try instead http://server:port/dir/cgi-bin/wikit.cgi/ -- the trailing slash apparently can be important.

Despite what I wrote below, setting the env variable WIKIT_BASE to http://server/cgi-bin/wikit/ before calling tclkit seems to fix the trailing slash requirement in the calling URL. --WL

You can also edit the exec line in the wikit. I changed mine to:
 exec /usr/bin/env WIKIT_BASE=http://server/cgi-bin/wikit/ /apache/bin/tclkit

Which serves the purpose of removing the trailing slash requirement AND making sure that the tclkit owned by nobody and in the apache bin directory is the one that gets run. -PSE

May 9, 2002 - There is a new version of wikit, see the WiKit home page at [5]. It differs from the previous code in that it keeps the wiki data in a separate MetaKit datafile, while the code is now a standard scripted document. This is not a rewrite, but it does consolidate all the latest changes, clean up lots of internal messiness, and it's much easier to alter without losing existing wikit page contents. This version can in fact be used alongside an existing "wikit.tkd" file, and manage the pages in it while ignoring the original scripts stored in wikit.tkd ...

This code will be used for the Tcl'ers Wiki itself real soon (just a bit more tweaking, testing, and a few more changes) -JCW

Any new instructions for getting the new version of wikit running under CGI? I'm getting the "Premature end of script headers" error message. I'm running Apache/1.3.20 Server and have "Hello World" type CGI scripts working fine.

One reason wikit can fail, is when the file is not writable when called as CGI, i.e. if this is not the same uid then you better make the datafile writable for all, and also the directory it lives in so the lock file can be created and removed -JCW

LV one thing I had to do in my wikit.cgi wrapper was cd into the directory where the wikit.tkd was created, so that when the wikit attempted to create the lock file, it would be in a directory with write permission.

The platform I used is netbsd on alpha with apache running as nobody.

I used the instructions at the end of http://wiki.tcl.tk/24 to get a local copy of the Tcl'ers Wiki running. I experimented with defining or not defining the WIKIT_BASE env variable; things seem to be ok either way. I also tried setting tclkit (the binary) suid to the user that owns the wikit.tkd, but it didn't seem to help. IE, I still had to make the wikit.tkd writable by everybody in order to make the wiki editable. However, making tclkit suid does let it write to the directory it is in without making the entire directory writable by everybody.

One confusing aspect of the instructions was the layout of the directory structure. In my ~/html directory, I created a wiki directory (mkdir ~/html/wiki). In that directory, I made my wrapper shell script wiki.cgi. apache lets cgis be called without the cgi extension, even though the actual cgi does have the .cgi extension. And since the slashes are used to separate things, the end url looks like "http://host/wiki/wiki/" to start, and "http://host/wiki/wiki/0" for the other pages.

To handle the separate datafile, I needed an empty wiki.tkd. So, I grabbed a windows version of tclkit (the one with tk) and ran "tclkit wikit.kit". This produces an "emtpy" wiki.tkd, which I moved over to the web server. Running tclkit as a cgi without the tkd file will sometimes create an empty tkd file, but will more often than not generate the Internal Server error and a premature end of header in the web server log file. Now, I have my own nearly empty wiki going.

--WL

Has anyone had any luck getting Wikit to function as a CGI under Windows? I've downloaded wikit.exe from the Starkit Distribution Archive [6] and it works fine through the local Tk GUI, but when I try to run it as a CGI process under Apache 2.0.40 (using http://localhost:8080/cgi-bin/wiki/wikit.exe/0) I get this error:
 An internal error was detected in the service software. The diagnostics are being emailed to the
 service system administrator ([email protected]).

I'm fairly sure this error isn't coming from Apache, as nothing's being added to the error log. I've also tried to write a batch script to set the WIKIT_BASE path and then start wikit.exe with similar results. Anyone have any ideas?

Wikit runs successfully with tclhttpd under M$ Windows 2000 as CGI-App (with a little wrapper.exe written in PowerBASIC). Bust it seems that one cannot change the PAGE TITELs just as in the local-wikit-gui. Any Ideas?

escargo 02 Feb 03 - Is this some Freudian Graffito, or should this really read, "But it seems that one cannot change the PAGE TITLEs just as in the local-wikit-gui"?

Wikit runs also just fine in windows (IIS), out-of-the box, with some little things with MS IIS. First, wikit uses PATH_INFO variable, which is by default not supported in IIS (or actually it is supported incorrectly, "This is by design, for security purposes"). You find more info and how it can be configured to run correctly from [7]

Then, you just install wikit quite like tcl in general to run under IIS [8]. The key is to use Application Settings -> Configuration" to map your file extension to an executable. I have simply mapped .tkd extension to C:\Progra~1\Tcl\bin\tclkitsh.exe wikit.kit "%s", which starts always wikit for the database given in the url, allowing me to run several wikits under same root directory.

-- rnurmi

See also Wikit configuration