Graphical design component

r18 - 16 Jul 2007 - 16:11:07 - TimSuttonYou are here: TWiki >  Geospatial Web > GeoAppInter > ServerPreparationStepByStep

Debian Install

Install Debian Etch on a clean machine (everything from here on assumes you have a clean install to start with. With minor variations these same instructions should work on Ubuntu.

Install ssh

sudo apt-get install openssh-server
sudo /etc/init.d/ssh restart

Enable all repositories in apt by editing /etc/apt/sources.list and uncommenting all lines starting with # deb. Also add the following:

deb http://ftp.us.debian.org/debian/ etch main contrib non-free

Then do:

sudo apt-get update

Install apache2, php5 and postgresql / postgis

sudo apt-get install php5-pgsql php5-cgi php5 php5-curl php5-xsl postgresql-8.1-postgis libapache2-mod-php5

Create a new admin user for PostgreSQL? so you dont need to use the postgres admin account. Do this for each user you want to have access to pg, giving them suitable permissions.

sudo su - postgres
createuser -s -d -r -P -E timlinux
Enter password for new role:
Enter it again:

Create the database backend and enable postgis extensions

createdb biogeosdi
createlang plpgsql biogeosdi
psql biogeosdi < /usr/share/postgresql-8.1-postgis/lwpostgis.sql
psql biogeosdi < /usr/share/postgresql-8.1-postgis/spatial_ref_sys.sql

Open PostgreSQL? so that it is accesible from any location trough TCP. Edit the pg_hba.conf and postgresql.conf

vim /etc/postgresql/8.1/main/postgresql.conf 

edit line 49 to listen_addresses = '*'

vim /etc/postgresql/8.1/main/pg_hba.conf

Add this line to the end of the file to allow connections from any host in the cria network host all all 200.144.120.0 255.255.255.0 trust

Install JAVA jdk5 and geoserver

First the jdk

sudo apt-get install sun-java5-jdk tomcat5

Set the java home var so we can find it:

sudo vim /etc/profile

Add to the bottom of the file this line then save

export JAVA_HOME=/usr
export GEOSERVER_HOME=/opt/geoserver

Then resource that file:

source /etc/profile

Now get geoserver with jetty

cd /tmp
wget http://ufpr.dl.sourceforge.net/sourceforge/geoserver/geoserver-1.5.0-RC3-bin.zip
unzip geoserver-1.5.0-RC3-bin.zip
cd /opt
mv /tmp/geoserver .
geoserver/bin/startup.sh

The deployed geoserver is now online at: http://omtest.cria.org.br:8080 example

Install Flex SDK and compiler

To be able to automatically deploy Flex applications when committing to the subversion directory we have to install the free flex SDK on the server to compile the source code. You can get a copy of the Flex SDK and compiler at Adobe (http://www.adobe.com/products/flex/).

First I have downloaded the SDK and compiler at /home/jatorre/flex2/flex_sdk_2.zip

Uncompress it:

unzip flex_sdk_2.zip

We will place at /usr/local/

sudo mv flex2 /usr/local/

Add it to the path

export PATH=$PATH:/usr/local/flex2/bin/

Now it should be working, try with:

mxmlc --version

You should get something like Version 2.0.1 build 155542

Install subversion client

Easy, just

sudo apt-get install subversion

Deploy script for Flex application

In order to automatically compile the latest version from source in the server a new script called deploy_flex.sh has been created in /home/jatorre (need to find a better place for it). This isthe content:

#!/bin/sh
#Update the local repository to get the latest source
svn update /home/jatorre/biogeosdiRepo/
#compile the software
/usr/local/flex2/bin/mxmlc /home/jatorre/biogeosdiRepo/trunk/frontend/flex/BioGeoSDI.mxml
cp -R /home/jatorre/biogeosdiRepo/trunk/frontend/flex /var/www/

As you can see there is a subverison working copy of the biogeosdi repository on the server that was before created using:

svn co https://biogeosdi.ecoforge.net/svn/biogeosdi/ /home/jatorre/biogeosdiRepo

It would be better to have a cleaner script that actually compiles an export of the source code, but we dont find it neccessary for this prototype and the export from the Kansas server can be quite slow, so this is more productive.

Finally I had to change the permissions of the /var/www/flex folder to 777 to allow anybody to run the deploy_flex.sh script (that is for example to be able to run it from a PHP script called from apache)

Install mapserver with python mapscript

From apt (currently we are using this way)

sudo apt-get  python-mapscript

Test the initial install is working by pointing your browser to : http://omtest.cria.org.br/cgi-bin/mapserv

Install Mapserver Data Files

cd /opt
svn co https://biogeosdi.ecoforge.net/svn/biogeosdi/trunk/data/
sudo chmod +x /opt
sudo chmod +wx /opt/data

or create a symbolic link from the /opt directory to the previously checked out biogeosdi/data:

cd /opt
sudo ln -s <workspace>/biogeosdi/data

Note: you should remove the .svn working directories or do an svn export above.

Install Test Environmental data layers

Test environmental data layers are available in subversion in the data directory

Check the WCS service by using the following URLs:

Capabilities: http://omtest.cria.org.br/cgi-bin/mapserv?map=/opt/data/mapfiles/hadley1990to1999.map&request=GetCapabilities&service=WCS

GetCoverage (right click and 'Save Link As', then open with an image viewer program): http://omtest.cria.org.br/cgi-bin/ogcdata.cgi/envlayers?request=GetCoverage&service=WCS&version=1.0.0&bbox=-180,-90,180,90&Coverage=annualTmpRange&crs=EPSG:4326&format=image/tiff&resx=1&resy=1

Install openModeller Web Service

Lets install the mapserver build deps as they will mostly cater for the build deps of openModeller

sudo apt-get build-dep python-mapscript

Now we can go ahead and build openModeller itself....

sudo apt-get install cmake libsqlite3-dev libgsl0-dev
cd ~
mkdir -p dev/cpp
cd dev/cpp
svn co https://openmodeller.svn.sourceforge.net/svnroot/openmodeller/trunk/openmodeller
cd openmodeller
mkdir build
cd build
cmake ..
make
sudo make install 

Add the /usr/local/lib dir to ldconfig.

sudo vim /etc.ld.so.conf

Now add this line:

/usr/local/lib

Now update:

sudo ldconfig

Now we can set up the openModeller soap server cgi. This is a bit ugly because we need to copy the server conf file into /usr/lib when it would be better in /etc

sudo cp /usr/local/bin/om_soap_server  /usr/lib/cgi-bin/om_soap_server.cgi
sudo mkdir /usr/lib/config
sudo cp /usr/local/share/openmodeller/server.conf /usr/lib/config
sudo chmod +x /usr/local/bin/scheduler.sh

Now you need to edit the server config for openModeller in /usr/lib/config/server.conf

#########################################################
## Configuration file for the openModeller SOAP server ##
#########################################################

## Directory where tickets should be stored 
## (user running the SOAP server needs write access to it!)
TICKET_DIRECTORY = /tmp/om/tickets/

## Directory containing the available layers to be exposed to the public
LAYERS_DIRECTORY = /opt/data/envdata

## Associated label for the root layers' directory
LAYERS_LABEL = OmTest Remote layers

## Directory where the map files should be created
## (user running the SOAP server needs write access to it!)
## (should be a directory exposed to the web)
DISTRIBUTION_MAP_DIRECTORY = /opt/data/models

## URL related to the directory where maps are created
BASE_URL = http://omtest.cria.org.br/models/

BASE_WCS_URL = http://omtest.cria.org.br/cgi-bin/ogctemp.cgi/

## Cache directory
CACHE_DIRECTORY = /tmp/om/cache/

We defined some temporary working dirs above so we need to make sure they actually exist:

mkdir -p /opt/data/models
mkdir /tmp/ms_tmp
mkdir -p /tmp/om/models
mkdir -p /tmp/om/cache/
mkdir -p /tmp/om/tickets/
sudo chown www-data.www-data -R /tmp/om
sudo chown www-data.www-data -R /tmp/ms_tmp

Whenever the machine is rebooted the contents of /tmp are purged so edit /etc/rc.local and add these commands to make sure everything is ready on machine startup:

#added by Tim to make sure tmp dirs etc are available on startup
mkdir -p /opt/data/models
mkdir /tmp/ms_tmp
mkdir -p /tmp/om/models
mkdir -p /tmp/om/cache/
mkdir -p /tmp/om/tickets/
chown www-data.www-data -R /tmp/om
chown www-data.www-data -R /tmp/ms_tmp
#this is an ugly hack to solve permissions problems
chmod -R a+rw /tmp/om
/opt/geoserver/bin/startup.sh &

Make sure you add them before the 'exit 0' command.

Now we need to set up a cron job (as www-data user) to ensure that models are queued properly

sudo su - www-data
crontab -e

Now add the following line to the cron file

# m h  dom mon dow   command
0-59/1 * * * * /usr/local/bin/scheduler.sh /tmp/om/tickets /tmp/om/models 10
0-59/1 * * * * /usr/local/bin/scheduler.sh /tmp/om/tickets /tmp/om/models 20
0-59/1 * * * * /usr/local/bin/scheduler.sh /tmp/om/tickets /tmp/om/models 30
0-59/1 * * * * /usr/local/bin/scheduler.sh /tmp/om/tickets /tmp/om/models 40
0-59/1 * * * * /usr/local/bin/scheduler.sh /tmp/om/tickets /tmp/om/models 50
#Delete the temporary datasets created by DPS service every 2 hours
0 2 * * * php5-cgi /opt/biogeosdiTrunk/backend/util/dps/delDatasetsWrapper.php

Create symbolic links in /usr/local/bin for python script to pull WCS data and register models and environmental layers

cd /usr/local/bin
sudo ln -s /opt/biogeosdiTrunk/backend/util/rasterDps/http.py
sudo ln -s /opt/biogeosdiTrunk/backend/util/rasterDps/mapservice.py
sudo ln -s /opt/biogeosdiTrunk/backend/util/rasterDps/template.map
sudo ln -s /opt/biogeosdiTrunk/backend/util/rasterDps/template.layer
sudo ln -s /opt/biogeosdiTrunk/backend/util/rasterDps/getAndRegisterEnvlayer.py 
sudo ln -s /opt/biogeosdiTrunk/backend/util/rasterDps/getAndRegisterModel.py

Additional notes for deploying on a different server

  • Edit /usr/local/share/openmodeller/server.conf and set the host name(s) in that file appropriately
  • Edit /opt/biogeosdi/config.inc.php and set the host name appropriately and add a google maps key generated for your host
  • Edit /usr/local/bin/scheduler.sh and replace om_create with /usr/local/bin/om_create and om_project with /usr/local/bin/om_project
  • If you update the data files from SVN you must remove teh .svn dirs in the env data dirs (though I suggest to use svn export rather):

sudo rm -rf /opt/data/envdata/.svn
sudo rm -rf /opt/data/envdata/hadley1990to1999/.svn/
Edit | Attach | Printable | Backlinks: Web, All Webs | History: r18 < r17 < r16 < r15 < r14 | More topic actions
 
Back to TDWG Homepage TDWG Wiki > Geospatial
This site is powered by the TWiki collaboration platform

Valid XHTML 1.0 Transitional
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback