source: trunk/workshop/2010/using_zoo_from_osgeolivevm.rst @ 729

Last change on this file since 729 was 725, checked in by djay, 9 years ago

Fix issue with rst files displayed from Trac. Fix strings to be translated. Always use the same string in all messages.

  • Property svn:keywords set to Date Author
  • Property svn:mime-type set to text/plain
File size: 8.2 KB
Line 
1.. _using_zoo_from_osgeolivevm:
2
3Using ZOO from an OSGeoLive virtual machine
4###########################################
5
6.. contents:: Table of Contents
7    :depth: 5
8    :backlinks: top
9
10`OSGeoLive <http://live.osgeo.org/>`__ is a live DVD and virtual machine based on  `Xubuntu <http://www.xubuntu.org/>`__ that allows you to try a wide variety of open source geospatial software without installing anything. It is composed entirely of free software and include ZOO 1.0 this year, for testing purpose.
11
12ZOO Kernel Installation
13***********************
14
15As already said in introduction, an OSGeoLive virtual machine image disk has
16been installed on your computer, allowing you to use ZOO Kernel in a development
17environment directly. Using a virtual machine image disk seems to be the simplest
18way to use ZOO Kernel and to develop ZOO Services locally, as we can ensure that
19everything requested for compiling C Services and running Python ones is available
20and ready to use. Every ZOO related material and source code have been placed in
21``/home/user/zoows`` directory. We will work inside it during this workshop. As
22the binary version of ZOO Kernel is already compiled and stored in ``/home/user/zoows/sources/zoo-kernel``,
23you only have to copy two important files inside the ``/usr/lib/cgi-bin``
24directory : ``zoo_loader.cgi`` and the ``main.cfg`` in order to make ZOO Kernel
25available, using the following commands :
26
27.. code-block:: guess
28
29    sudo cp ~/zoows/sources/zoo-kernel/zoo_loader.cgi /usr/lib/cgi-bin
30    sudo cp ~/zoows/sources/zoo-kernel/main.cfg /usr/lib/cgi-bin
31
32
33Please note that we will talk about ZOO Kernel or ``zoo_loader.cgi`` script without
34any distinction during this workshop.
35
36The ``main.cfg`` file contains metadata informations about the identification and
37provider but also some important settings. The file is composed of various sections,
38namely main, identification and provider per default. Obviously, you are free to add
39new sections to the file if you need them for a specific Service. Nevertheless, you
40have to know that the env and lenv sections name are used in a specific way.
41
42The env section lets you define environment variables that your Service requires
43during its runtime. For instance, if your Service requires to access to a X server
44running on framebuffer, then you will have to set the ``DISPLAY`` environnement
45variably, in this case you would add ``DISPLAY=:1`` line in your env section.
46
47As for the env section, there is the section lenv where specific informations about
48status informations of a running Service will be written by the ZOO Kernel or the
49ZOO Services. For instance, when your service failed, you can set the value for
50message in lenv to see it displayed in the Status node of the ExecuteResponse
51returned back to the client. If your service will take long time and can get
52informations about processing status, you can then set a value between 0 and 100
53to status in lenv to represent the percentage completed of the running Service task,
54we will talk deeper about this later in this workshop.
55
56Please take a look to your local file ``main.cfg`` file. Three important parameters are commented bellow:
57
58  - serverAddress : The url to access to the ZOO Kernel
59  - tmpPath : The full path to store temporary files
60  - tmpUrl : The url path relative to serverAddress to access temporary directory.
61
62The values of the main.cfg file used from the running virtual machine are the following :
63
64.. code-block:: guess
65
66    serverAddress=http://localhost/zoo
67    tmpPath=/var/www/temp
68    tmpUrl=../temp/
69
70You could have noticed that the tmpUrl is a relative url from ``serverAddress``,
71so it must be a directory. Even if ZOO Kernel can be used with the full url of
72the ``zoo_loader.cgi`` script, for better readability and fully functional ZOO Kernel,
73you have to modify the default Apache configuration in order to be able to use the 
74http://localhost/zoo/ url directly.
75
76First, please create a ``zoo`` directory in the existing ``/var/www`` which is
77used by Apache as the ``DocumentRoot``. Then, please edit the ``/etc/apache2/sites-available/default``
78configuration file and add the following lines after the ``Directory`` block related to ``/var/www`` directory :
79
80.. code-block:: none
81
82    <Directory /var/www/zoo/>
83        Options Indexes FollowSymLinks MultiViews
84        AllowOverride All
85        Order allow,deny
86        allow from all
87    </Directory>
88
89Now create a small ``.htaccess`` file in the ``/var/www/zoo`` containing the following lines:
90
91.. code-block:: guess
92
93    RewriteEngine on
94    RewriteRule call/(.*)/(.*) /cgi-bin/zoo_loader.cgi?request=Execute&service=WPS&version=1.0.0&Identifier=$1&DataInputs=sid=$2&RawDataOutput=Result [L,QSA]
95    RewriteRule (.*)/(.*) /cgi-bin/zoo_loader.cgi?metapath=$1 [L,QSA]
96    RewriteRule (.*) /cgi-bin/zoo_loader.cgi [L,QSA]
97
98For this last file to be taken into account by Apache, you must activate the
99rewrite Apache module by copying a load file as bellow :
100
101.. code-block:: guess
102
103    sudo cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
104
105Or using the ``a2enmod`` tool this way :
106
107.. code-block:: guess
108
109    a2enmod rewrite
110
111Now you should be able to access the ZOO Kernel using a simplified by restarting your Apache Web server :
112
113.. code-block:: guess
114
115    sudo /etc/init.d/apache2 restart
116
117
118Two other softwares form the OSGeoLive environment will be used during this workshop.
119MapServer will first be used to provide WFS input data for the ZOO Services we are
120going to develop. The MapServer dataset providen by Orkney (japanese regions polygons)
121will be passed to our service during `section 4 <http://zoo-project.org/trac/wiki/ZooWorkshop/FOSS4GJapan/CreatingOGRBasedWebServices#CallingthesinglegeometryservicesfromJavaScript>`__.
122
123OpenLayers library is also available on the OSGeoLive virtual machine image disk,
124and it will be used during `section 4 <http://zoo-project.org/trac/wiki/ZooWorkshop/FOSS4GJapan/CreatingOGRBasedWebServices#CallingthesinglegeometryservicesfromJavaScript>`__, for building a simple WPS client application able to query the newly developed ZOO Services.
125
126As we planned to use OGR C-API and Python module of the GDAL library, we will need
127the corresponding header files, libraries and associated files. Hopefully everything
128was already available per default and so ready to use on the OSGeoLive packaging.
129
130Testing the ZOO installation with GetCapabilities
131*************************************************
132
133
134You can now simply query ZOO Kernel using the following request from your Internet browser:
135
136http://localhost/cgi-bin/zoo_loader.cgi?Request=GetCapabilities&Service=WPS
137
138You should then get a valid Capabilities XML document, as the following :
139
140.. image:: ./images/Practical-introduction-to-ZOO-2.png
141   :width: 458px
142   :height: 159px
143   :align: center
144
145Please note that no Process node is returned in the ProcessOfferings section, as no
146ZOO Service is available yet. You can also proceed to a GetCapabilities request from
147the command line, using the following command:
148
149.. code-block:: none
150
151    cd /usr/lib/cgi-bin
152    ./zoo_loader.cgi “request=GetCapabilities&service=WPS”
153
154The same result as in your browser will be returned, as shown in the following screenshot:
155
156.. image:: ./images/Practical-introduction-to-ZOO-3.png
157   :width: 395px
158   :height: 251px
159   :align: center
160
161Invoking ZOO Kernel from command line can be helpful during development process of new Services.
162
163Preparing your ZOO Services Provider directory
164**********************************************
165
166In order to simplify the task, we will first comment the directory structure which
167should be used when creating a new Services Provider :
168
169  - The main Services Provider directory including :
170
171    - A ``cgi-env`` directory which will contain all the zcfg metadata files and the service shared object (C Shared Library or Python module)
172    - The ``Makefile`` and the ``*c`` files needed to compile your Services Provider.
173
174Please create a ws_sp main Services Provider directory in the existing zoo-services one located in ``/home/user/zoows/sources/``, respecting the tree above .
175
176.. code-block:: guess
177
178    mkdir -p /home/user/zoows/sources/zoo-services/ws_sp/cgi-env
179
180The Makefile and the code of the C and Python Service Shared Object will be detailed in the next sections.
181
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png