Next edit the file "config.h" in the top level directory. You should enter the host name of the computer on which you plan to run wn and the complete path name of your data directory. If you want to run at a port other than 80 also edit the DEFAULTPORT entry. You should also specify the complete path of the file lib/mime.types on your system. You can put this file anywhere convenient (and give it any name). This file is used by the wndex program to specify the correspondence between file name suffixes and MIME content type. See the section below on Content-type for a more detailed explanation of the function of this file.
Other customizations in config.h are possible but should not be needed. You may also edit the file "Makefile" in the top level directory to specify the C compiler used if you wish to use something other than cc, e.g. gcc.
In the top level directory do a "make" to produce the server wn, the standalone version swn and the utility "wndex". This utility is used to produce "index.cache files" for use by the server (it is described below). If the "make" proceeds without problem you should next do a "make install". This will strip the binaries and place them in the top level bin directory or whatever directory you specified as BINDIR in the top level Makefile.
You can now either run the server as a standalone daemon, the swn executable, or run under inetd, the wn executable. We first describe the standalone version. Run this with the command
swn -p port [other options] /path/to/wnroot
where "port" is the number of the port on which you wish the server to run. If this is a non-privileged port (i.e. > 1024) then swn can be run as an ordinary user. However, for privileged ports like 80 you must run the command above as root. If swn is run without the -p option it will use port 80 by default. When swn starts up it will change its user id to the one set in the config.h file line where USERID is #defined.
The other way to run the server is to use it under inetd. There are variations on how this works from system to system so you may need to look at the man page for inetd.conf(5). Here's how it works under many systems, e.g. SunOS 4.1.3: Edit the file /etc/services and create the line
wn 80/tcp
(or replace 80 by the port you wish to use). Then edit the file /etc/inetd.conf and insert the line
wn stream tcp nowait nobody /full/path/for/wn wn
After the last wn you can have optional arguments to turn on logging or use a different data directory. Some inetds limit the number of argu ments you may use so I prefer to use a small script in place of wn here. My inetd.conf line looks like
wn stream tcp nowait nobody /full/path/for/wnwrap wnwrap
and wnwrap contains only the two lines
#!/bin/sh
exec /full/path/for/wn -t 202 -L /my/log/file /my/WN/root/dir
It is important to run wn as "nobody" (the fifth field in the inetd.conf line above) or some other user with no access privileges. If you are using an inetd with without the capability to set UID on startup (e.g., Ultrix), you should define the group ID and user ID in config.h so that the program is not running as root (look for the #defines USERID and GROUPID and set the values appropriately). It should never be necessary to run wn under inetd as root and to do so would be a serious mistake for maintaining security. Every attempt has been made to make wn as secure as possible, even if it is run as root, however, no program accessible to remote users on the internet can be assumed perfectly secure. (See the security guide).
After editing the inetd.conf and services files you should find the process id number of the inetd process and do the command "kill -HUP pocess_id#". This must be done as root. If you have never done this before, get someone who has to help you.
Now you are ready to test your server installation on this directory. Try it with your favorite HTTP client. The URL should be
http://YourHost/docs/index.html
First if the compilation of wn failed and produced an error message like
ld: Undefined symbol
_putenv
it means that the C programming libraries on your system do not
contain the function putenv(). For four functions, which
seem to be less commonly available than they should be, versions have been supplied.
They are putenv(), strncasecmp(), strstr() and strftime(). To use them you
will need to edit config.h and uncomment the line #define NEED_PUTENV,
for example.
If the compilation was successful you can check the server itself by
executing it from the command line. If you use the command "wn
/full/path/of/root/dir", it should run and pause for input. Type the
line
GET /
and in response wn should print the raw HTML of the index.html
file in your top level directory.
If instead you type
GET /docs/overview.html
or (and you still have the /docs subdirectory in your top level
directory) the overview document should be sent to your screen.
If this doesn't happen there should be an error message which may be
helpful. Better error messages are placed in the log file so you may
want run wn again with the additional arguments "-L logfile" and then
examine the contents of the logfile. Or if you run "wn -L /dev/tty"
the log entries will be printed to your screen instead of being put in
a file. If the server can't open a file, for example, the name of that file
will be recorded in the logfile. Check its permissions. Remember that
all files that wn serves must be world readable. A second useful test is to telnet to your server at port on which you are running. You should get a connection message and a pause for input. If you get a "Connection refused" message it is likely there is a problem with your inetd setup or for some reason your system can't find or can't execute the wn binary.