To appear in the October issue of Campus Computing and Communications

Setting up your own WWW Server

The only thing thing more exciting than surfing the web is publishing your own information on the web. If your web master has no way to let you put documents on the local server, you'll have to run your own World Wide Web HTTP server. In this article I'll describe how to set up the NCSA httpd HTTP server on a UNIX host and provide some general advice for those wishing to put up their own server. Anyone with experience installing software on UNIX can easily follow the instructions.

This document is available on-line at ``http://www.cs.ubc.ca/spider/phillips/webserv''.

The first thing you'll want is a web browser for testing your server and reading documentation, most of which is on-line. Next you'll need a suitable host. A production service should be on a host that runs 24 hours a day 7 days a week -- this is, after all, a world-wide web and you'll see accesses at every hour of the day. Let's call this host ``host.SITE.ubc.ca''.

I'm using the NCSA server as my example because it's reasonable, but there are others. See ``http://www.w3.org/hypertext/WWW/Daemon/Overview.html'' for a list. The ``CERN'' and ``gn'' servers are also popular. You can obtain httpd from ``ftp://ftp.ncsa.uiuc.edu/Web/httpd/Unix/ncsa_httpd/current''. They have pre-compiled binaries there and source code. For a Sun 4 running SunOS 4.*, grab ``httpd_sun4.tar.Z''. Use the source code in ``httpd_source.tar.Z'' if there's no binary for your host.

Unpack and compile as necessary in a suitable source code directory. You must choose a directory for the documents and a directory for the server binary and configuration files. I'll use ``/usr/local/www/docs'' for the documents and ``/usr/local/www/httpd'' for the the rest. Go to the httpd_1.3 directory (just under where you unpacked httpd) and rough in the configuration with the following commands:

mkdir /usr/local/www /usr/local/www/docs /usr/local/www/httpd
mkdir /usr/local/www/httpd/conf /usr/local/www/httpd/logs
cp httpd /usr/local/www/httpd
cp conf/mime.types /usr/local/www/httpd/conf
cp -r icons /usr/local/www/docs

Create the basic configuration files in ``/usr/local/www/httpd/conf''. First, the main server configuration file, ``httpd.conf''. Replace SITE in the following with something to make valid-looking e-mail and host names.

ServerRoot /usr/local/www/httpd
ServerName www.SITE.ubc.ca
ServerAdmin webmaster@SITE.ubc.ca
Port 8080
User #-2
Group #-2
ServerType standalone
ErrorLog logs/error_log
TransferLog logs/access_log
PidFile logs/httpd.pid
AccessConfig conf/access.conf
ResourceConfig conf/srm.conf
TypesConfig conf/mime.types
IdentityCheck off

Second, put this in the main access control file ``access.conf''.

<Directory /usr/local/www/docs>
Options Indexes FollowSymLinks
AllowOverride None
<Limit GET>
order allow,deny
allow from all
</Limit>
</Directory>

Finally, fill the server resource file ``srm.conf'' with:

DocumentRoot /usr/local/www/docs
UserDir DISABLED
DirectoryIndex index.html
FancyIndexing on
AddIconByType (TXT,/icons/text.xbm) text/*
AddIconByType (IMG,/icons/image.xbm) image/*
AddIconByType (SND,/icons/sound.xbm) audio/*
AddIcon /icons/movie.xbm .mpg .qt
AddIcon /icons/binary.xbm .bin
AddIcon /icons/back.xbm ..
AddIcon /icons/menu.xbm ^^DIRECTORY^^
AddIcon /icons/blank.xbm ^^BLANKICON^^
DefaultIcon /icons/unknown.xbm
ReadmeName README
HeaderName HEADER
IndexIgnore */.??* *~ *# */HEADER* */README*
DefaultType text/plain

Whew, we're almost there. All we need now is a home page. Here's one to start with. Place it in ``/usr/local/www/docs/index.html''.

<HEAD><TITLE>Home page for SITE.ubc.ca</TITLE></HEAD>
<BODY><H1>SITE.ubc.ca Home Page</H1>
Welcome.  We have <A HREF="[unarchived-link]">some icons</A>!
<P><HR>Your Name (webmaster@SITE.ubc.ca)</BODY>

We can now run the server and see if it works. Do so with the commands:

cd /usr/local/www/httpd
./httpd -f conf/httpd.conf

It will fork itself into the background. Try out your new home page by opening the URL ``http://host.SITE.ubc.ca:8080/''. If you get an error, check things over and try again. If it still doesn't work, you may have to read the ``official'' httpd documentation at ``http://hoohoo.ncsa.uiuc.edu/docs/''. Either way take a look at it to get a better understanding of what you just did and what's possible.

Your basic server is now functional and ready for experimentation. Before you announce it for public use you need to do a few more administrative things. Use the standard port number -- I used 8080 to allow any user to try this. Change the ``Port'' line in ``http.conf'' to read ``Port 80''. It is an excellent idea to have an alias for your server to make moving it easier. Ask your local domain name server administrator to make www.SITE.ubc.ca an alias for host.SITE.ubc.ca. Those changes give your home page the more appealing URL of ``http://www.SITE.ubc.ca/''.

Create a ``webmaster@SITE.ubc.ca'' e-mail alias for your HTTP server administrator. It's a standard contact address much like ``postmaster'' is for e-mail.

Finally, you'll want the server to start when the machine is booted. This is an amazingly system dependent thing, but on SunOS machines tagging the following lines onto ``/etc/rc.local'' should do the trick:

if [ -f /usr/local/www/httpd/httpd ]; then
    /usr/local/www/httpd/httpd -f /usr/local/www/httpd/conf/httpd.conf
fi

When you're done, send some e-mail to phillips@cs.ubc.ca and have your web site added to the list of UBC web sites. Then you can start filling the server with documents, using GIF images, learning about CGI, trimming logs files, generating server usage statistics and all kinds of wonderful stuff. Good luck and I hope to see many more UBC web sites pop up as we move into the 90s.


George Phillips is a system manager for the Department of Computer Science and is pretty sure his HTTP server was the first in British Columbia.