OS/2 eZine - http://www.os2ezine.com
Spacer
16 July 2001
 
John Bijnens is a CAM/CAM engineer in the KHLim - Dep. IWT which is some kind of technical university in Belgium. He gives training in Pro/E and also writes CNC postprocessors (all development is done on OS/2.)

If you have a comment about the content of this article, please feel free to vent in the OS/2 eZine discussion forums.

There is also a Printer Friendly version of this page.

Spacer
Previous Article
Home
Next Article


DBExpert - Relational Database - Application Builder - http://www.sundialsystems.com/dbexpertos2ezine


WEB/2

When we talk about a web server on an OS/2 system, most people automatically think about Apache/2 or Lotus Domino GoWebserver. Lotus Domino GoWebserver is a beautiful web server that comes with Warp Server for eBusiness, is native OS/2, but as far as I know is sadly discontinued by IBM.

Apache/2 is a port of the Linux version to OS/2. This port is done with the aid of the EMX libraries. There is also a native Apache/2 v2.0 being developed at this very moment which doesn't need the EMX libraries anymore. Apache 1.3.19 had some security problems, it could be crashed fairly easily from outside.

So I was looking for something else and found Web/2, native OS/2, written in Pascal and compiled by Virtual Pascal, probably the best code generating Pascal compiler for OS/2. Web/2 is freeware and incredibly small (the size of the executable is only 42K.)


How to install Web/2

Installation is very easy. Download three packages from dink.org Create a directory where you want to install Web/2 in, e.g. F:\Web2 Now unzip all packages in this directory. You see the following files and directories

You can also unzip the file sample.zip It contains some cgi-examples.

How to configure Web/2

General settings : web.cfg

First of all start setup.exe. This creates some additional configuration files like alias.cfg, mime.cfg, and cgi.cfg and allows you to specify some general settings.

Web Port

This is the TCP/IP port the Web/2 server will be listening to. You don't need to change this as 80 is the standard port for the http protocol.

Logging

If this is on, Web/2 will create a log file 'web.log' that contains a listing of every web server access. This log file can be used to check who has accessed your server and see what they've been looking at.

Logfile Style

With this setting you can specify the format of the log file. You have two options :

web/2 this activates the web/2 log format which gives you very detailed information.
ncsa/apache this enables the same format as used by ncsa and apache httpd servers. This allows you to analyze the log with standard log analyzers like e.g. http-analyze, analog, etc.

If you want to switch between these formats, e.g. from web/2 to ncsa/apache because you want to use a log analyzer, you have to start a new log. You can do this by renaming the old log.

Resolve ip's

this enables host name lookup. This means that the IP-address of every computer that accesses the web server will be looked up through the name server. So instead of seeing 193.190.57.4 as the name of the user accessing the web server, you will see voyager. This option comes in very handy when you want to have the log analyzers generate an overview of the domains your visitors come from. If you don't need this, you can turn this option off to avoid the overhead of consulting the name server with every web server access.

send() Blocksize

This option allows you to adjust the size of the blocks that the web server sends. You probably don't want to play with this.

File-list if no index.html

With this option you can allow/disallow the web server to send a list of the files in the requested directory if there is no index.html present in this directory. This is known as directory browsing and for security reasons it might be a good idea to disable this option.

Main HTML directory

The name of this option speaks for itself. This doesn't necessarily need to be the directory where the HTML pages of you web site are located.

CGI-BIN directory

This is the directory where your cgi scripts must reside in order to get executed.

File-list icons directory

This is the directory where the icons reside that are used for the representation of the file list when you have enabled "File-list if no index.html" and no file index.html is present in the requested directory.

When you exit setup.exe all settings are written in the configuration file web.cfg If Web/2 is running while you are changing these general settings you have to restart it to activate the new settings.

Example of the native Web/2 format

Connection From: voyager @ Jul 9, 2001 3:04pm
Browser: Mozilla/4.61 [en] (OS/2; U)
Sending: index.htm
Connection From: voyager @ Jul 9, 2001 3:04pm
Browser: Mozilla/4.61 [en] (OS/2; U)  Referer:
http://193.190.57.1/
Sending: powerd.gif
Connection From: 192.168.1.62 @ Jul 9, 2001 3:04pm
Browser: Mozilla/4.61 [en] (OS/2; U)
Sending: index.htm

Example of the NCSA/Apache compatible format

voyager - - [09/Jul/2001:15:13:21 +0000] "GET / HTTP/1.0" 200 454 "" "Mozilla/4.61 [en] (OS/2; U)"
voyager - - [09/Jul/2001:15:13:21 +0000] "GET /powerd.gif HTTP/1.0" 200 2215 "http://193.190.57.1/" "Mozilla/4.61 [en] (OS/2; U)"

Example of a File listing

The icons that are used in this representation are the ones found in the directory specified with the option File-list icons directory. You can create your own icons to customize the look according to your own wishes.

Connection time in window

In the image below you can see the window of Web/2 where the date and time of the last web server access are given.

Specifying aliases and virtual domains : alias.cfg

Web/2 allows you to create aliases and virtual domains with separate log files.

Contents of a alias.cfg

index.htm          index.html
e:\WebSite_CelKunststoffen virtual:celkunststoffen.khlim.be log:celkunststoffen.log
d:\users\jimmy\Kwaliteitssysteem virtual:Kwaliteit log:kwaliteit.log
e:\testdrive\html\stat.html        stat.htm
c:\os2\utils                  /os2utils/
index.htm       index.html

Aliases allow you to have the web server serve up one file instead of another, so for example, every time someone tries to access index.html Web/2 will redirect this request and send instead the file index.htm So if you have two different files index.html and index.htm only index.htm gets opened. If you don't want this behavior and want both index.html and index.htm to be able to get opend you have to delete this entry.

Virtual hosts allow a single web server to provide web serving services to more than one domain. To create a virtual host celkunststoffen.khlim.be add the line:

e:\WebSite_CelKunststoffen virtual:celkunststoffen.khlim.be log:celkunststoffen.log

When someone visits http://celkunststoffen.khlim.be the file index.htm that's present in the directory e:\WebSite_CelKunststoffen will get opened. Every access to this site is logged in a file celkunststoffen.log that will be created in the directory Web/2 is installed in.

You can assign multiple hosts to the same IP-address. This way you can have multiple web sites on the same IP-address. Be aware of the fact that all the domain names you use (celkunststoffen.khlim.be, ...), must be registered at a name server. Otherwise they can't be accessed.

Web/2 offers you the possibility of creating aliases for html files and directories. Suppose the IP-address of the computer Web/2 is running on is 193.190.57.4

e:\testdrive\html\stat.html     stat.htm
c:\os2\utils                    /os2utils/

When a visitor accesses the URL http://193.190.57.4/stat.htm you expect that the web server will send the file stat.htm that's located in the main HTML directory. Instead the server will send the file e:\testdrive\html\stat.html

When a visitor accesses the URL http://193.190.57.4/os2utils/ you expect that the web server will send the file index.htm (if it is present) that's located in the directory /os2utils/ that can be found in the main HTML directory, or in case there is no index.htm, the file listing of that directory is shown. Instead the server will redirect /os2utils/ to c:\os2utils

Specifying mime types and extensions : mime.cfg

One of the configuration files that's generated after running setup.exe is mime.cfg This file holds all the mime types and extensions that are known to Web/2. This is normally used by the Web/2 server to make it possible for web browsers like Netscape to recognize the correct file type. When you don't do anything extraordinary it isn't necessary to edit this file.

Specifying cgi command extensions : cgi.cfg

One of the configuration files that's also generated after running setup.exe is cgi.cfg. This file holds all the extensions of the executables, rexx files, perl scripts, etc. that are allowed to run as a cgi file.

When creating cgi files for use with Web/2 keep in mind that

  • The cgi-bin, icons and virtual includes dirs under virtual hosts are the same as a non-virtual host.
  • The "startup" directory of cgi's is the same dir as web.exe. According to the documentation accompanying Web/2 90% of the cgi's Dink has tested work flawlessly, the other 10% worked with only small modifications.

Contents of the standard cgi.cfg

internal .exe .cmd .cgi
!php.exe .php .phtml .php3 .php4
perl.exe .pl .perl

Some very nice SSI tags

SSI stands for Server Side Includes. These are tags that are interpreted by the web server itself before sending the file to the browser of the visitor to your site.

<blocksize> the defined send() blocksize Web/2 uses.
<browser> the type of browser the visitor of your web site is using to access the page.
<connections> the number of connections that have been established by Web/2 since it has been started up.
<date> the current date.
<host> the hostname of the machine that gives the visitor access to your site. If your visitor is behind a proxy server, then this is the hostname of the proxy server.
<IP> the IP address of the machine that gives the visitor access to your site. If your visitor is behind a proxy server, then this is the IP address of the proxy server.
<referer> this identifies where the link to this page is coming from. This is also logged in the ncsa/apache style log file whether you use this tag or not.
<sysuptime> this gives the uptime the PC Web/2 is running on.
<textcounter> this is a counter that gives the number of times a specified page is hit. This is used in conjunction with a file counter.dat.
<time24> this is the local time on the PC Web/2 is running on in 24h format.
<time> this is the local time on the PC Web/2 is running on in 12h format.
<web2uptime> this is the time Web/2 has been running.
<webversion> this gives the version number of Web/2.

There is an example file stat.htm in the directory html that can be used an example on how to use SSI tags.

Contents of stat.htm

<html>
<head><title>web/2 statistik page</title></head>
<br>
your host / ip: <host> <ip><br>
your browser: <browser><br>
your referer: <referer><br>
web/2 version: <webversion><br>
web/2 blocksize: <blocksize><br>
os/2 uptime: <sysuptime><br>
web/2 uptime: <web2uptime><br>
connections: <connections><br>
date/time: <date> <time><br>
</html>

Output of stat.htm when accessed through a link on another HTML-page

your host / ip: merlin 127.0.0.1
your browser: Mozilla/4.61 [en] (OS/2; U)
your referer: http://merlin/
web/2 version: v1.3w
web/2 blocksize: 32768
os/2 uptime: 0 days 0:44:27
web/2 uptime: 0 days 0:00:26
connections: 13
date/time: Jul 10, 2001 9:25pm

If you want to show how many times a page is accessed by using the SSI tag <textcounter> you must make an entry for this page in the file counter.dat that can be found in the directory Web/2 is installed in.

Suppose you have a file f:\index.htm and you want to make a counter for this page. Somewhere in this page you have something like

This page has been accessed times.

Now make the following entry in the file counter.dat
f:\index.htm 0
Every time this html page is accessed the counter will be incremented. If your page has been accessed 5 times the following output will be generated by Web/2 to the browser

This page has been accessed 5 times.

and you see that the line you've entered in counter.dat has changed to
f:\index.htm 5

How to start Web/2 ?

After configuring, starting Web/2 is very easy. Just execute web.cmd and you're running. Don't forget that every time you change one of the configuration files you have to restart Web/2 to activate the new settings.

Where can Web/2 be found and Additional information

As mentioned before, you can download Web/2 from the author's site dink.org.

Dink (the author's nickname) has programmed some other fine software packages. The most known is probably z! a very fine MP3 player which can be also be used as a helper application in Netscape in order to play MP3 streams.

You can contact the author at http://dink.org/email

Don't forget that all this software is written by the author in his own spare time so if you like this software, please send a sign of life and your appreciation to him. This way he knows his work is valued very much and it will give a stimulation to develop new versions. If anything isn't working as expected don't start to yell, try to provide the author with a full reproducible error report so he is able to correct the problem in case of a bug.

And Then

And then it is up to you. Give Web/2 a try.



Web/2
Author: dink
Price: Free
Website: http://dink.org/web2/

Previous Article
Home
Next Article

Copyright (C) 2001. All Rights Reserved.