# OpenClinica User Manual/Ubuntu1010
## Installing OC 3.0.4.1 on UBUNTU 10.10 Server

This document describes process of installing OpenClinica version 3.0.4.1 on the Linux UBUNTU Server version 10.10

### Installing required software
#### PostgreSQL database
##### To install Postgresql on Ubuntu10.10 do the following:

* apt-get update
* apt-get install postgresql-8.4
* default TCP port for PostgreSQL: 5432
* configuration files (for version 8.4): /etc/postgresql/*
* cluster data (for version 8.4): /var/lib/postgresql/{version}/{cluster}/*
* set up password for PostgreSQL account: postgres
** su postgres
** psql postgres
** ALTER ROLE postgres WITH ENCRYPTED Password “yoursecretpassword”;
** Login into PostgreSql database using new password: psql –hlocalhost –U postgres –W

##### If you want to setup Remote access for PostgreSql:

* Modify /etc/postgresql/{version}/{cluster}/postgresql.conf:
listen_address = “IP_address, localhost” and save
* Modify /etc/postgresql/{version}/{cluster}/pg_hba.conf:
Add following line: host ALL ALL IP/mask md5
* Restart PostgreSQL: service postgresql restart or /etc/init.d/postgresql restart
* If you have firewall open port TCP 5432

##### If you want to check if postgresql is running:

* netstat –ant | grep 5432
* ps –aux | grep postgres
* psql --version
* chkconfig --list | grep postgresql

#### Apache Tomcat 6 and JDK 6

To install Tomcat 6 and JDK 6:
* apt-get update
* apt-get install openjdk-6-jdk tomcat6 tomcat6-admin tomcat6-common tomcat6-docs tomcat6-examples
* Apache Tomcat 6 configuration files: /etc/tomcat6
* CATALINA_BASE and CATALINA_HOME = /var/lib/tomcat6
* TCP default port: 8080
* http://ip_address:8080
* JDK6:
** JAVA_HOME: /usr/lib/jvm/
** java –version // to check current version of JVM
At this stage we should have all required application installed on the system required for OpenClinica.

#### OpenClinica

OpenClincia application requires access to directory where e.g.CRFs, data extract sets etc will be stored once application is running. You can create this anywhere on your server as long as it is accessible by tomcat6 user (in this document by you may wish to create different user to run tomcat server). I e.g. have under /var/OpenClinica/ all the folders used by all the instances of OpenClinica installed on my server (it will make easier as well to do backup of your OpenClinica data).
General steps required to set up OpenClinica web application, data folder and PostgreSQL database:
* Please download version of OpenClinica you would like to install unzip and read installation notes (recommended).
* Create role, database on PostgreSQL database used by OpenClinica installation (appropriate scrips are included in the file you download from OpenClinica web site).
* Prepare data folder for OpenClinca and make sure that tomcat6 user can read and write to this location; You may create under: /var/OpenClinica/{OC_instancename}/ two folders:
** One with data for OpenClinica
** Second with logs for OpenClinica instance
* Deploy OpenClinica.war (by changing the name of the war file you can deploy more than one instance of OpenClinica on your Apache Tomcat 6 server)
* Either follow the instruction how to deploy war file on the Apache Tomcat 6 server or use Tomcat WE Application Manager
* Allow up to 1 minutes to deploy your new installation on the Apache Tomcat 6 server (it depends of course how much memory, and CPU has your server, check if java is doing by issuing top command):
* You should have under tomcat6 “webapps” folder with the OpenClinica instance
* Stop tomcat 6 server: service tomcat6 stop
* Edit file for your instance /var/lib/tomcat6/webapps/{OC_instanceName}/WEB-INF/classes/datainfo.properties
** You have to provide path to the OpenClinica data folder for this instance
** Username, password and database for PostgreSQL server
* Start tomcat6: service tomcat6 start
Depending on CPU and memory this step may take up to few minutes to finish (you may monitor activity of java process using top command tool) If everything went fine you should be able to access your instance: http://IP_tomcat6_server:8080/OpenClinica_instancename

### Enable SSL support on Apache Tomcat 6

See: http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
We will use SSL using APR (SSL self-signed server certificate and private key):
* Install additional packages:
* apt-get update
* We install native library and APR libraries
* apt-get install libtcnative-1 libapr1 libaprutil1
* Edit tomcat 6 configuration file: /etc/tomcat6/server.xml
* Enable APR listener
* Enable SSL over APR:
* Specify parameter for SSL connection
* Path to the SSL server certificate
* Path to the SSL server private key
* Restart tomcat6 server: service tomca6 restart
* netstat –ant | grep 8443 //check if sever is listening on the default 8443 TCP port for tomcat 6 for SSL connection

### Backup /Restore of OpenClinica
#### Backup

* we have to backup the OpenClinica instance files
* Apache Tomcat 6 configuration files
* PostgreSql configuration files
* Data folder for OpenClinica instance
* Database for OpenClinica

#### Restore

* Not done yet