Logo address

Installation of Pegasus

目次

2003/01/11 updated
Here I explain how to install Pegasus that does not use CGI.

Installation

  1. get pegasus-2.0b.tgz
  2. unpack
    term% gunzip pegasus-2.0b.tgz
    term% tar -xf pegasus-2.0b.tar
    then directory pegasus will be created in the directory in which you execute tar. Let this directory be $pegasus.
  3. compile
    term% cd pegasus
    term% cd httpd
    term% mk lib
    term% mk
  4. install
    The default installation place is:
    /usr/local/bin/386
    Create the directory and:
    term% mk install

Troubles in compilation

If compiler complains:
	main: undefined: estrdup in main
please comment out estrdup in emem.c. The function is now in library and your system might be old.

Creating /usr/web

The directory /usr/web is a base directory on which Pegasus configures namespace.( You can use other directory in /sys/lib/httpd.conf)
	term% mkdir /usr/web
You need not register user web to /adm/users if you do not run Pegasus as server mode. Don't owner of /usr/web be web. Give permission to others to execute and read.
Copy $pegasus/example/usr/web to /usr/web. The copy is easy if you use my tool cpdir. You can get cpdir from http://plan9.aichi-u.ac.jp/netlib/cmd/.
	term% cpdir -mv $pegasus/example/usr/web /usr/web
Never set these directory owner to be web. Permit others to read and execute.
example/usr/web is configured for CGI, therefore there are needless directories if you do not use CGI. I think they are harmless.
Don't place web content under /usr/web/doc. This directory is something like a dish to which web content is dynamically bound.

The directory where web content is really placed

Web content of real or virtual host is placed under your home directory. If you are bob then
	/usr/bob/www/doc
is recommended directory.
Content of user is placed under
	$home/web/doc
where $home is home directory of the user. Let the user be alice, then the home page will be accessed from the client with URI
	http://your.host.com/~alice
where your.host.com is domain name of your server.

/sys/lib/httpd.rewrite

Let assume the document root of real host is /usr/bob/www/doc. Write a line
/	*/usr/bob/www
in /sys/lib/httpd.rewrite. Special setting of user's web root is not required.

/lib/namespace.httpd

You can use distributed file $pegasus/sample/lib/namespace.httpd as it is. Although the content is configured for CGI, I think harmless.

Run Pegasus under listen

It is much easier to run Pegasus under listen then to run in server mode.
Create
	/rc/bin/service/tcp80
with the content
	#!/bin/rc
	exec /usr/local/bin/$cputype/httpd $*
and access mode
	--rwxrwxr-x

Confirm Pegasus does service

Assume your user name is bob. Make a HTML document
	/usr/bob/www/doc/index.html
and try to access using a browser.

Access control and security

Pegasus serves only files under document root. Document root in this case is:
	/usr/bob/www/doc
Httpd will see the directory as
	/doc
Note that we have two expression for same directory.
The former is called real space and the latter service space.

Pegasus rejects to send a file that begins with period `.'.

Besides above two generic rules you can define directories that can be controlled by IP or password. The control files are in

	/usr/bob/www/etc
For details see access control.