Testing your own CGIs with a real server

This is basically straight forward. I'll outline it using csh. The assumption is that you already have a ~/public_html directory and a ~/public_html/cgi-bin directory that contains your CGI programs.

Create a ~/www directory

This will contain the server's configuration and log files.
	mkdir ~/www ~/www/log
	(cd /usr/local/www; tar cf - conf icons) | (cd ~/www; tar xvfp -)

Create the server configuration files

You'll need to select a port number to use. For this example I use 1234. You'll probably need to select a different one.
	set port=1234
	pushd ~/www
	cat - << EOF > ~/www/conf/httpd.conf
ServerType standalone
Port $port
ServerAdmin $user@csi.uottawa.ca
ServerRoot $cwd
ErrorLog log/httpd_log
TransferLog log/httpd_access_log
PidFile log/httpd.pid
EOF
	popd

	pushd ~/public_html
	sed -e "/^DocumentRoot/s: .*: ${cwd}:" \
		-e '/^ScriptAlias/d' -e '/^Redirect/d' \
		/usr/local/www/conf/srm.conf > ~/www/conf/srm.conf
	echo "ScriptAlias /cgi-bin/ $cwd/cgi-bin/" >> ~/www/conf/srm.conf
	popd

Start the server

The easy bit!
	/usr/local/www/httpd -d ~/www
You can then point netscape to your server using something like this:
	netscape `hostname`:`sed -n -e '/^Port /s/^Port //p' ~/www/conf/httpd.conf` &
ie. assuming you started your server on csia and were using port 1234:
	netscape csia:1234 &

Stop the server

When you've done, it's only polite to remove the server. This is easy:
	kill `cat ~/www/log/httpd.pid`
You may also want to clean out the log files:
	rm ~/www/log/*

webmaster@csi.uottawa.ca

Last update 1996/06/25