[ Team LiB ] Previous Section Next Section

The TclHttpd Distribution

Get the TclHttpd distribution from the CD-ROM, or find it on the Internet at:

ftp://ftp.tcl.tk/pub/tcl/httpd/

http://www.tcl.tk/software/tclhttpd/

http://www.sourceforge.net/projects/tclhttpd

Quick Start

Unpack the tar file or the zip file, and you can run the server from the httpd.tcl script in the bin directory. On UNIX:

tclsh bin/httpd.tcl -port 80

This command will start the Web server on the standard port (80). On UNIX, you need to be root to run a server on this port. By default TclHttpd uses port 8015 instead. If you run it with the -help flag, it will tell you what command line options are available. If you use wish instead of tclsh, then a simple Tk user interface is displayed that shows how many hits the server is getting.

On Windows, you can double-click the httpd.tcl script to start the server. It will use wish and display the user interface. Again it will start on port 8015. You will need to create a shortcut that passes the -port argument, or edit the associated configuration file to change this. Configuring the server is described later.

Once you have the server running, you can connect to it from your Web browser. Use this URL if you are running on the default (nonstandard) port:

http://hostname:8015/

If you are running without a network connection, you may need to specify 127.0.0.1 for the hostname. This is the "localhost" address and will bypass the network subsystem.

http://127.0.0.1:8015/

Inside the Distribution

The TclHttpd distribution is organized into the following directories:

  • bin — This has sample start-up scripts and configuration files. The httpd.tcl script runs the server. The tclhttpd.rc file is the standard configuration file.

  • bin/mini — This has a few tiny versions of the server that provide a basic server in about 300 lines of code. Use these as a starting point by modifying the HttpdRespond procedure.

  • bin/test — This has a number of test scripts, including the torture.tcl file that can fetch many URLs at once from a server.

  • certs — This has sample certificates you can use to test a secure server for https URLs. If you have your own server certificates, put the server.pem file here.

  • config — This contains autoconf support used by C extensions you can build with the server.

  • custom — This is where you put your own custom code. Files here are automatically loaded by the server on startup. This contains a few samples.

  • doc — This has a UNIX-style manual page for how to run the server.

  • htaccess — This has sample access control files.

  • htdocs — This is a sample URL tree that demonstrates the features of the Web server. There is also some documentation there. One directory to note is htdocs/libtml, which is the standard place to put site-specific Tcl scripts used with the Tcl+HTML template facility.

  • lib — This has all the Tcl sources. In general, each file provides a package. You will see the package require commands partly in bin/httpd.tcl and partly in bin/httpdthread.tcl.

  • src — There are a few C source files for a some optional packages. These have been precompiled for some platforms, and you can find the compiled libraries under src/Solaris and src/Linux.

    [ Team LiB ] Previous Section Next Section