Version 66 of Tclhttpd Winservice

Updated 2008-12-02 12:45:48 by MHo

From time to time, I'm working on a starpack based on tclhttpd v 3.5.1 which can be run as a Windows Service through the help of Winserv. Additional descriptions are at the bottom and some more probably will be added later.

However, the starpack can be run as a normal program too, not only as a service.

You can download the current version (0.89) here: .

Example cmdline help: (note that it may differ from release to release and from environment to environment as some defaults like paths are constructed dynamically)

tclhttpd.exe 0.85, based on tclhttpd 3.5.1 and Tcl 8.4.19, modified 24.11.2008 22:41:52, MHo usage: tclhttpd.exe {options|scriptfile}

 -virtual value       Virtual host config list <>
 -config value        Configuration file <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/tclhttpd.rc>
 -main value          Per-Thread Tcl script <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/httpdthread.tcl>
 -docRoot value       Root directory for documents <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/../htdocs>
 -port value          Port number server is to listen on <8015>
 -host value          Server name, should be fully qualified <matthias>
 -ipaddr value        Interface server should bind to <>
 -https_port value    SSL Port number <8016>
 -https_host value    SSL Server name, should be fully qualified <matthias>
 -https_ipaddr value  Interface SSL server should bind to <>
 -webmaster value     E-mail address for errors <[email protected]>
 -uid value           User Id that server runs under <50>
 -gid value           Group Id for caching templates <50>
 -secs value          Seconds per "minute" for time-based histograms <60>
 -threads value       Number of worker threads (zero for non-threaded) <10>
 -library value       Dir list where custom packages and auto loads are <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/../custom>
 -debug value         If true, start interactive command loop <0>
 -compat value        Version compatibility to maintain <3.3>
 -gui value           Flag for launching the user interface <1>
 -mail value          Mail Servers for sending email from tclhttpd <>
 -LogFile value       Location and name prefix for logfiles <s:/tmp/log>
 -tclcgi value        Runtime to execute tcl-CGIs <C:/Programme/Tcl/bin/tclsh.EXE>
 -AuthDefaultFile value Location for internal authfile <s:/tmp/tclhttpd.default>
 -unpacktools         Extract included tools and docs
 -morehelp            Show a few background infos
 -help                Print this message
 -?                   Print this message

Output of -morehelp

 This Webserver is based on tclhttpd v3.5.1 and a tcl runtime (either a tclkit
 or a basekit ActiveTcl, e.g.).

 This starpack is designed to run as a Windows service through Winserv. It can
 be started interactively, too.

 The VFS-internal htdocs and libs are stripped down somewhat to reduce exe
 size. They are always available unter /adminroot. The CGI demos will not run
 out of the VFS! Code from internal custom dir is loaded first. The 'real'
 custom dir is expected to be outside the VFS, because it's subject to
 changes all the time. Also, it's likely that you will have your own

 On windows, the auto_path is automatically extended to the lib folder of an
 existing Tcl installation (auto_execok tclsh/../lib). If there is such an
 installation, it also runs Tcl-CGIs. If not, tclkitsh is searched. The last
 fallback is that this program also runs the CGIs.

 An example for installing this starpack as a service:

 winserv install httpd1 -ipcmethod stdio -start demand -description "tclhttpd1"
  -user .\xyz -password abc d:/progs/tclhttpd.exe -config d:/my/httpd.rc
  -library d:/my/custom
 winserv start httpd1

 tclhttpd.exe is under development, so the .exe will change frequently.

 things that could be done or should be noticed:
   - incorporate changes/fixes from later (3.5.2/CVS)-versions
   - replace the cmdline/config-parsing with Spar and readprof (see wiki)
   - adapt new homepage (see and; a dummy is available at /home2.html
   - create config/tclhttpd.rc equivalents for the newly added cmdline switches
   - add support for more cgi interpreters (php, ...) (no #!-magic on MS Win)
   - reimplement PAUSE and CONTINUE functions in a better way, and implement
      service control e.g. to query several states of the server
   - eventually add separate event logging for Windows eventlog, and/or
     reorganize the whole stdout/stderr/console output stuff
   - (Re-)integration of wikit (whipit), see
   - look further at https:-Support

 ! * use the right account for the service; watch the environment, especially
 !   the PATH-var (additional env-vars could be added through custom code)
 ! * avoid using backslashes in command line arguments; they are not yet
 !   automatically translated

 M.Hoffmann, 2006-2008

(As said, the program will change from time to time and so will this help text.)

To access the build in docs and admin-tools, simply start tclhttpd without any parameters and navigate your browser to localhost:8015. These are always available via url /adminroot even if you have configured your own docRoot (some links may still not work yet).

To implement tclhttpd as a service, you need Winserv, which is available inside tclhttpd.exe an can be extracted via -unpacktools command line switch.

RLH 2006-04-10: Why version 3.4.2 when 3.5.1 is the latest release? MHo I tried 3.5.1 several times and never succeeded in getting it servicing our existing intranet site, driven by 3.4.2/3.4.3 without modifications. It seems to me that there are some changes that are not upward compatible (probably in doc.tcl). I'm working on this. 2006/07/18: v3.5.1 is now the base of my modifications. Remember: Specifying URLs without the .tml-extension only works anymore with documents specifying [Doc_Dynamic]...


  • 25.04.2006: Switched to one of the latest dqkit-runtimes (threaded).
  • 12.05.2006: Done auth for /admref (not reflected in -morehelp yet). UserID and password are fixed for now to webadm, /#&goony+
  • 23.05.2006: Switched to tclhttpd v3.5.1; changes not yet reflected here or elsewhere (testing and config in progress). My personal homepage space is exhausted, so I'm currently not able to post any new releases...
  • 18.07.2006: Many many changes to make v3.5.1 work; too many to note them here. Command line changed, help changed accordingly. Basic functionality should be ok now.
  • 28.07.2006: Switched to winserv's -ipcmethod stdio. Several internal changes to work around difficulties with service-mode etc.
  • 25.08.2007: New Version 0.5 with some enhancements (many module and documentation updates and some additions, e.g. tcllib 1.9). Runtime is base-tclsh from Activestate, version 8.4.15. As usual, the changes are not documented in detail here. If interested, post a note here.-
  • 18.10.2007: v0.6 with Tclruntime 8.4.16, some internal docs updated, some unusable code ZIPed, integrated gzip updated, .EXE-size reduced, modules from newest tcllib.
  • 23.10.2007: modified lib/tclhttpd/fallback.tcl to avoid generating double slashes // at the beginning of an URL (see [L1 ])

History for v0.7 and above:

25.10.2007-02.11.2007, v0.7:

  • if no interpreter for CGIs is found, CGIs are interpreted by tclhttpd.exe itself!
  • removed some *Nix-specifica, because this is primilary designed to be a windows program
  • removed Ajuba- and ScripticsLogo*.GIF from htdocs/images (not referenced anywhere)
  • textutil/*.tex replaced by 0 Byte-dummies (not referenced anywhere)
  • htdocs/manual/htdig.html and references removed (very old and for *Nix only)
  • bin/* (crypt etc.) removed (only *Nix)
  • htdocs/snmp* removed (only makes sense with Scotty and with *Nix, I guess)
  • removed obsolete backup-ZIPs from VFS
  • gzip.exe + docs removed; Logfiles are now ZIPped internally (external gzip.exe only as a fallback) I hope this internal zipping does not the block the whole server for too long periods...
  • Reduced size by ~200k

25.01.2008, v0.8, MHo (sorry: not tested very well yet):

  • bugfix in log.tcl, ZIPped logs where not deleted...
  • runtime now is base-tcl-thread-win32-ix86.exe v8.4.17 from ActiveTcl
  • updated doctools, mime and fileutil and associated manpages
  • removed unneccessary module env from cgi-bin/ (*NIX ELF binary makes no sense with Windows) and multiple occurence of some README
  • reduced overall EXE size by approx. 4k

27.01.2008, v0.81, MHo:

  • fixed bug in command line / .rc-file processing (LogFile in .rc has been ignored, internal default always took precedence. Had to specifiy command line switch to overwrite.)

09.07.2008, v0.82, MHo: Time for some changes ;-)

  • Runtime is base-tcl-thread-win32-ix86.exe from ActiveTcl v8.4.19
  • the used parts of textutil updated to v0.71
  • md5crypt updated to v1.10
  • doctools updated to v1.3.2
  • removed unused stuff from zipper/pkgIndex.tcl
  • fixed htdocs/notfound: 'home'-link returns to / instead to non-existing cgi-bin/index
  • fixed bug in newauth (updated to v0.4) and updated documentation for newauth (still "eine Baustelle")

23.09.2008, v0.83, MHo:

  • Runtime base-tcl-thread-win32-ix86.exe
  • Refreshes from tcllib 1.10:
  • fileutil
  • md5, md5crypt
  • mime
  • ncgi
  • cmdline
  • base64
  • doctools

20.11.2008, v0.84, MHo:

  • Fixed an awfull bug which prevents from loading if a certain regkey was missing (regkey only present if ActiveTcl installed)...
  • Removed some critcl code from rc4c, md5c, md5cryptc (makes no sense here)
  • Experimental 64bit-Version [L2 ], which probably won't run as a service, because winserv.exe and nologoff.dll are still 32bit. Not tested yet.
  • Experimental Version with Tcl 8.5.5 runtime [L3 ]. Should work but don't... There's a difference I don't understand yet in httpdthread.tcl preventing VFS-internal custom code from loading... (see below)
  • Sometimes, under some circumstances with have to do with the internal httproot, pageloads never come to an end.

26.11.2008, v0.85, MHo:

  • Minor changes.

28.11.2008, v0.86, MHo:

DGP I need clarification on this. Is there a bug in glob in Tcl 8.5.5 ? Is it reported? What other releases have the same bug and what releases do not? MHo: I tried to illustrate the problem at the very bottom of this page.

  • some internal manpages not up to date, I think. Maybe I remove all this stuff in the future, because it's available somewhere.

29.11.2008, v0.87, MHo:

30.11.2008, v0.88, MHo:

  • Now using iocpsock (error that some GIFs don't load from internal VFS (/adminroot/images)still present!; iocpsock not tested very well yet)
  • minor corrections

01.12.2008, v0.89, MHo:

  • fixed: program won't run out of folder with blanks in it's name (various symptoms, e.g. mime.types don't get loaded etc.)
  • minor corrections

Glob problem w/8.5.5???


 httpd % glob $::starkit::topdir/bin/../custom/*
 no files matched glob pattern "D:/Home/Hoffmann/pgm/tcl/usr/Src/httpd351pack4/tc
 httpd % glob $::starkit::topdir/custom/*
 root.tcl D:/Home/Hoffmann/pgm/tcl/usr/Src/httpd351pack4/tclhttpd8.5.5_32.exe/cus
 tom/extend_auto_path.tcl D:/Home/Hoffmann/pgm/tcl/usr/Src/httpd351pack4/tclhttpd
 8.5.5_32.exe/custom/faq.tcl D:/Home/Hoffmann/pgm/tcl/usr/Src/httpd351pack4/tclht
 tpd8.5.5_32.exe/custom/fix3.5.tcl_ D:/Home/Hoffmann/pgm/tcl/usr/Src/httpd351pack
 4/tclhttpd8.5.5_32.exe/custom/hello.tcl D:/Home/Hoffmann/pgm/tcl/usr/Src/httpd35
 1pack4/tclhttpd8.5.5_32.exe/custom/htmlutils.tcl D:/Home/Hoffmann/pgm/tcl/usr/Sr
 c/httpd351pack4/tclhttpd8.5.5_32.exe/custom/mypage.tcl D:/Home/Hoffmann/pgm/tcl/
 usr/Src/httpd351pack4/tclhttpd8.5.5_32.exe/custom/newauth.dat D:/Home/Hoffmann/p
 gm/tcl/usr/Src/httpd351pack4/tclhttpd8.5.5_32.exe/custom/newauth.tcl D:/Home/Hof
 httpd %