*** DRAFT *** DRAFT *** DRAFT *** DRAFT *** DRAFT *** DRAFT *** DRAFT *** DRAFT

Currently there is no binary release of Corporate Office, so you have to
compile it by yourself. It is in most cases more complicated than usual
./configure && make && make install, so read on.

All instalation script are intended for use with Red Hat 6.x and should
be run as root.

1. Install Linux

Corporate Office was tested on Red Hat Linux 6.2.
It should compile and run on any recent distribution based on glibc 2.1
and GNU C Compiler (egcs-2.91.66 was used for development).
You will need development tool, including perl. On Red Hat 6.2,
package groups "Networked Workstation" and "Development" are enough to
build and run Corporate Office.

Corporate Office should build and run on RedHat 7.0, however it was tested
on RH 6.2 only. RedHat 7.0 ships with new development version of gcc
and you can expect a lot of warnings (mostly due to the new preprocessor).
Also there are other issues making installation on RedHat 7 not recommended 
for this pre-beta release.

2. Install Apache

Apache 1.3.x (1.3.12 or later) is required. You need devel package to build 
Corporate Office.
RPM package contained in Red Hat 6.2 will work but CO is intended to run
with mod_ssl, so package containig apache-mod_ssl is distributed with CO.
Apache should run as user 'nobody'.
Check that your Apache works before you install CO.

For more information on Apache HTTP server: http://www.apache.org


3. Install PostgreSQL

Version 7.0.x with perl support is required. Also, support for long object names
is required (128 characters).

Source distribution of PostgreSQL with install script for Red Hat 6.2 
is distributed with CO.

PostgreSQL has to be started before Apache.
Add two users to PostgreSQL (system accounts): 
account of httpd server ('nobody'; does not create databases or users)
account of user installing CO (usually 'root', has to be able to create databases)

For more information on PostgreSQL database server: http://www.postgresql.org

WARNING: On RedHat 7 Apache runs as user apache. Option DBConn of CO config file 
(/opt/co/conf/co.conf by default) allows to set database, user name and password 
used to log on to database (it is PostgreSQL connection string; e.g 
"dbname=nobody user=john password=ZXCVBN").

4. Install JavaScript.

CO requires recent (1.5 Release Candidate 1 or later) version of Netscape 
JavaScript implementation (as included with newer Mozilla releases).

This library was renamed 'libmozjs.so' to avoid collisions with other
implementations of JavaScript.

Additional library 'libmozjsdebug.so' created for debugging
JavaScript scripts in Corporate Office is required. It is available
as source code with CO (archive jsdebug-*.tar.gz).

For more information on JavaScript engine: 
 http://www.mozilla.org/js/spidermonkey/


5. Install CO

Run configure with appropriate options.
Usually, you need to add PostgreSQL and JavaScript library and include paths 
to configuration and you have to set the path to PostgreSQL sources.

By default database 'nobody' is used. You may want to change database name
with --with-database=NAME option.

Contents of the database will be deleted during (re)installation.

It is possible to have multiple copies of Corporate Office binaries installed.
Default installation paths are found using apxs tool (installed with apache;
if you do not have it, you should install apache-devel package - or whatever 
it is called in your distribution).

--with-apache-libexecdir="/usr/lib/apache-2" - here apache modules are kept

--with-apachectl="/etc/rc.d/init.d/httpd-2"  - tool used to start/stop apache
   (it should recognize options start and stop)

--with-co-serverroot="/etc/httpd-2" - points to the directory where generated
    submodules, javascript, html and (usually) configuration files are kept

configure creates file co.conf. Copy it to a directory accessible for 'nobody'
and add it to Apache configuration, e.g. modify in httpd.conf
#AccessConfig conf/access.conf
to look like:
AccessConfig /path/to/co.conf

In co.conf modify option "Allow from ..." for you network.
 
Now run ./rebuild_all.
If it succeeded, copy contents of ./http_root to a directory mentioned
as CORootPath and COHtmlLibPath in co.conf.
Make sure that subdirectories 
attachment/data
text_document/data
are writable by 'nobody' (in order to create attachment and text_documents).

Browse http://<server address>/co or https://<server address>/co.

Example:
On development server there is alternative copy of Corporate Office running
on port 8888 (on separate copy of Apache server).
/etc/httpd-2 is ServerRoot of both the Apache server and Corporate Office.
JavaScript is placed in /etc/httpd-2/co_javascript, submodules in
/etc/httpd-2/co_modules, configuration in /etc/httpd-2/co_conf.
The main module (i.e. "Apache module", mod_*.so) is put into /usr/lib/apache-2,
together with other modules used by this copy of Apache.
Script used to configure looks like this:
===
COINSTDIR="/opt/co"
JSINSTDIR="${COINSTDIR}/js"
PGINSTDIR="${COINSTDIR}/pgsql"

PGVERSION="7.0.2"
PGSRCDIR="/usr/src/co/postgresql-${PGVERSION}/src"

./configure --with-libs="${JSINSTDIR}/lib ${PGINSTDIR}/lib" \
--with-includes="${JSINSTDIR}/include ${PGINSTDIR}/include" \
--with-postgresql="${PGINSTDIR}" --with-postgresql-src="${PGSRCDIR}" \
--with-database="marcin" --with-apachectl="/etc/rc.d/init.d/httpd-2" \
--with-co-serverroot="/etc/httpd-2" --with-apache-libexecdir="/usr/lib/apache-2"
===