source: main/waeup.kofa/trunk/docs/INSTALL.txt @ 13758

Last change on this file since 13758 was 13698, checked in by Henrik Bettermann, 9 years ago

Fix :pyobject: option.

File size: 14.6 KB
RevLine 
[11381]1Installation of Kofa
2####################
[10120]3
[12967]4These are generic installation instructions for the WAeUP_ Kofa
[11381]5student information portal and customized versions thereof.
[10120]6
[11381]7For specific aspects of this package please refer to the local README
8file.
[10120]9
[11381]10Please note, that **only Linux-based installs** are described and actively
11supported. We recommend use of Debian_ / Ubuntu_.
[11323]12
[11381]13.. note:: This means we do not actively support Windows(tm)!
[11323]14
[12864]15.. contents:: Table of Contents
16   :local:
[11323]17
[12968]18.. _prerequisites:
[11384]19
[11381]20Prerequisites
21*************
[11323]22
[11381]23The Kofa packages are based on `Grok`_, which is a Python_
[13075]24framework for agile web application development. Grok_ itself is based
[11381]25on `Zope`_.
[11323]26
[11381]27Both, Grok_ and Zope_, are written in the `Python`_ programming
28language (with parts written in C). You therefore have to have
29`Python`_ installed (including `Python`_ headers).
[11323]30
31
[11381]32Preparing the System
[11323]33====================
34
[12967]35For a Kofa install we need of course `Python`_ installed as well as
[11381]36some standard developer tools like C compilers, C libraries, etc.
[11323]37
38What you need (Debian/Ubuntu package names in brackets):
39
[11381]40* Python 2.7 (``python2.7``)
[11323]41
[11381]42* Python 2.7 development files (``python2.7-dev``)
[11323]43
[11381]44* A C-Compiler with basic C developer libraries (``build-essential``)
[11323]45
[11527]46* A subversion client (``subversion``)
[11323]47
[11527]48* XML and XSLT development libraries (``libxml2-dev``, ``libxslt1-dev``)
49
[13690]50* Other helper libraries, especially for image processing support
51  (``zlib1g-dev``, ``libssl-dev``, ``libffi-dev``, ``libjpeg-dev``,
52  ``libfreetype6-dev``, ``libtiff-dev`` ``libopenjpeg-dev``)
53
[11381]54* enscript (``enscript``) [optional]
[11323]55
56  This is only needed if you want test coverage reports.
57
58All these packages can be installed on Debian systems like this::
59
[11527]60  $ sudo apt-get install python2.7 python2.7-dev subversion \
[13690]61                         build-essential enscript libxml2-dev libxslt1-dev \
[13698]62                         zlib1g-dev libssl-dev libffi-dev libjpeg-dev \
63                         libfreetype6-dev libtiff-dev libopenjpeg-dev
[11323]64
65Afterwards you should be able to enter::
66
67  $ python2.7
68
[11381]69at the commandline and get a Python_ prompt. Quit the interpreter
[11323]70pressing <CTRL-D>.
71
[13690]72The above packages have been tested to be sufficient for running Kofa
73on Ubuntu 14.04. We check this with Docker images created at
[11323]74
[13690]75   https://github.com/WAeUP/kofa-docker
76
77This project provides tags that refer to certain Kofa versions.
78
79Please note: to make freetype2 work correctly with Kofa [#]_, you have to
80fix a link::
81
82  (root) $  ln -s /usr/include/freetype2 /usr/include/freetype2/freetype
83
84
85
86
[11323]87Installing `virtualenv`
88=======================
89
[11382]90We strongly suggest use of `virtualenv`_ to create Python_ sandboxes
91where you can run your code without touching any other installations.
[11323]92
[12967]93`virtualenv`_ is also the only possibility to build a Kofa install
[11382]94without the need of superuser permissions. In short: `virtualenv`_
95will make your life easier. Use it.
[11323]96
[11382]97Detailed install instructions for `virtualenv`_ can be found on
98http://www.virtualenv.org/en/latest/virtualenv.html#installation.
[11323]99
[11382]100The short way for a user install (no superuser perms required) is like
101this::
[11323]102
[11382]103  $ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.4.tar.gz#md5=9accc2d3f0ec1da479ce2c3d1fdff06e
104  $ tar xvfz virtualenv-1.11.4.tar.gz
105  $ cd virtualenv-1.11.4
106  $ python virtualenv.py py27
[11323]107
[11382]108Superusers can install `virtualenv`_ system-wide much easier. On
109`Debian`_/`Ubuntu`_ systems where you have superuser permissions, you
110can install `virtualenv`_ via::
[11323]111
[11382]112  $ sudo apt-get install python-virtualenv
[11323]113
[11401]114*Or*, if `pip` is installed already (superusers can install it via
115 ``sudo apt-get install python-pip`` on `Debian`_/`Ubuntu`_)::
[11323]116
[11382]117  $ sudo pip install virtualenv
[11323]118
119
[11402]120Creating a Sandbox
[11323]121==================
122
[11383]123After installing `virtualenv`_ you can install local sandboxes like
[11401]124this (if `virtualenv` is installed system-wide)::
[11323]125
[11383]126  $ virtualenv --no-site-packages py27
[11323]127
[11401]128*or* like this::
129
130  $ python /path/to/my/virtualenv.py --no-site-packages py27
131
[11383]132where ``py27`` is a directory in the filesystem where your sandbox
133will be created. `virtualenv` will also create this directory for
[11401]134you. While you can pick any sandbox name you want, it is recommended
135to use a sandbox name that is short and at the same time reflects the
136Python version used (here: Python 2.7).
[11323]137
138By passing the ``no-site-packages`` switch we tell `virtualenv` to
[11401]139provide a clean environment without any extra-packages installed
[11383]140systemwide. More recent versions of `virtualenv`_ have this option set
141by default.
[11323]142
[11383]143Another often used option of `virtualenv`_ is ``-p``. With ``-p`` you
144can tell `virtualenv`_ which Python executable to use as base for the
145new sandbox.
146
[11323]147You now can activate the sandbox by doing::
148
[11383]149  $ source py27/bin/activate
150  (py27)$
[11323]151
[11401]152You will notice that the input prompt changes, indicating the name of
153the sandbox activated.
[11323]154
155To deactivate the sandbox at any time, enter::
156
[11383]157  (py27)$ deactivate
[11323]158
159and the prompt will be the same as before the activation.
160
161For the following steps make sure the sandbox is active.
162
163
[11402]164Getting the Sources
165===================
[11323]166
[11401]167Now, as the sandbox is activated (see above, if not), we can fetch the
168sources for Kofa.
[11323]169
[11401]170As Kofa is currently available from the Subversion_ repository only,
171we use the Subversion_ client `svn` and checkout the main devel branch
172of the `waeup.kofa` package like this::
[11323]173
[11401]174  (py27)$ svn co https://svn.waeup.org/repos/main/waeup.kofa/trunk
[11323]175
176The command should fetch the Kofa base package sources for you and
[11401]177will put everything in a new directory ``trunk/``.
[11323]178
179Now enter the new directory::
180
[11401]181  (py27)$ cd trunk/
[11323]182
[11401]183and you can start building the real package.
[11323]184
[11401]185.. note:: If you not want to work with the `waeup.kofa` package but a
186          customized package (like ``waeup.aaue`` or similar), then
187          you can use the above checkout command but with
188          ``waeup.kofa`` replaced by the name of the customized
189          package::
[11381]190
[11401]191            (py27)$ svn co https://svn.waeup.org/repos/main/<PKG-NAME>/trunk
[11381]192
[11401]193          For the exact link, please refer to the README.txt file in
194          your package.
195
196
[11402]197Bootstrapping the Build
198=======================
199
200After `Creating a Sandbox`_ and `Getting the Sources`_ we have to
201initialize the newly created development environment::
202
203  (py27)$ python bootstrap.py
204
205This should create a local ``bin/`` directory with at least a script
206``buildout`` in it.
207
208If bootstrapping fails, chances are, that you need the `distribute`
209package installed. In a virtual environment you can install it without
[11703]210interfering with other packages installed on your server::
[11402]211
212  (py27)$ pip install --upgrade distribute
213
214Afterwards you have to retry the bootstrapping, until you get a
215working ``buildout`` script in the local ``bin/`` directory.
216
217Once the ``buildout`` script exists, you do not have to activate the
218virtual envronment any more (although you can).
219
220
[11381]221Part 1: Single Client Setup
222***************************
223
[12967]224You can run Kofa with a single client (useful for evaluation,
[11401]225development, etc.) or with multiple clients running in parallel. The
226latter setup is useful in productive environments with many thousands
[11402]227users and called a ``ZEO`` install. We will cover both setup
228types. The first is covered here, the latter one is covered in `Part
2292: ZEO Install`_.
[11401]230
[11402]231
[11404]232Building the Package
233====================
[11323]234
[11404]235In the sources directory (``trunk/``) you have to prepare the
[11323]236project to fetch needed components (eggs), compile C-code parts,
[11404]237etc. This is done by a single command ``buildout``::
[11323]238
[11404]239  $ ./bin/buildout
[11323]240
241If this is your first install of some Grok-related project, this step
242will need some time as lots of sources have to be fetched, many
243components must be compiled, etc.
244
245This step must be redone whenever you change something in
[11404]246``buildout.cfg``, ``buildout-zeo.cfg``, or ``setup.py``.
[11323]247
248Note that if you have more than one sandbox for a Zope-based web
249application, it will probably make sense to share the eggs between the
250different sandboxes.  You can tell ``zc.buildout`` to use a central
251eggs directory by creating ``~/.buildout/default.cfg`` with the
252following contents::
253
[11385]254  [buildout]
255  eggs-directory = /home/bruno/buildout-eggs
[11323]256
[11404]257where the given directory should be exist beforehand. All eggs of all
258`buildout` projects will then be stored in this directory (and not
259fetched anew if already existing there).
[11323]260
[11404]261
262Start the Instance
[11323]263==================
264
265You should be able now to start the created instance by doing::
266
[11404]267  $ ./bin/kofactl fg
[11323]268
[11385]269Alternatively you can do::
[11323]270
[11404]271  $ bin/paster serve parts/etc/deploy-themed.ini
[11323]272
273The port numbers where Kofa is running on your server are defined in
[11404]274`buildout.cfg` under ``[kofa_params]``.
[11323]275
[11404]276If you now point a browser to the right port on your server, for example::
[11323]277
[11385]278  localhost:8080
[11323]279
280you should get a login pop-up, where you can login as superuser with
281``grok`` and ``grok`` as username/password (Kofa base package only!).
282
283You can stop the instance by pressing <CTRL-C>.
284
285If you are connected and logged in,
286you should be able to add the grok-based applications
287(such as ``University``) from the menu.
288
289Add an instance of ``University`` and click on the link next to the
290then visible entry in the list of installed applications.
291
[11404]292Running the Tests
[11323]293=================
294
[11404]295All WAeUP_ packages come with comprehensive test suites ensuring the
296software quality also after changes and updates.
[11323]297
[11404]298The package tests are easily run by executing the test runner
299from the ``bin`` directory::
[11323]300
[11404]301  $ ./bin/test
[11323]302
[11404]303Use the ``-c`` option to get coloured output. Use the ``--pdb`` option
304to start the Python_ debugger when a test fails.
305
306
[11402]307Part 2: ZEO Install
308*******************
[11323]309
310Each ZEO install consists of at least one ZEO server and normally two
311or more ZEO clients. While the ZEO server is meant to manage the ZODB
312database for clients, the clients connect to the outside world, listen
313for request and do the real dataprocessing.
314
315We prepared a `buildout` configuration that sets up one server
316configuration and two client configs. This configuration is in
317``buildout-zeo.cfg``.
318
[11405]319Generating the ZEO Setup
[11323]320========================
321
322To install Kofa ZEO-based you can run `buildout` with the given
323(or your own) configuration file like this::
324
325  $ ./bin/buildout -c buildout-zeo.cfg
326
327This should generate all scripts necessary to run servers, clients,
328etc.
329
[11405]330Starting ZEO Servers and Clients
[11323]331================================
332
333First start the server::
334
335  $ ./bin/zeo_server start
336
337Clients can be started by doing::
338
339  $ ./bin/zeo_client1 start
340  $ ./bin/zeo_client2 start
341
342This will start both clients in daemon mode.
343
344Instead of ``start`` you can, as usually, start an instance in
345foreground (``fg``), etc. You know the drill.
346
347
[11405]348Manually Starting ZEO Clients
[11323]349=============================
350
351This is normally not neccessary.
352
353``zeo_clientN`` scripts are basically wrappers around calls to
354``bin/paster``. You can bypass this wrapper and start a client
355'manually' like this::
356
357  $ ./bin/paster serve --pid-file var/zeo1.pid --daemon \
358        pars/etc/zeo1.ini
359
[11405]360It is important to give a pid-file as `paster` otherwise can not start
[11323]361different clients (they would all refer to the same pid file
362`paster.pid` and refuse to start after the first client was started).
363
364
[13270]365Setup (parameters, ports, etc.)
366===============================
[11323]367
368By default the server will listen on port 8100 for requests from
369localhost (not: from the outside world).
370
371You can change ZEO server settings in the ``[zeo_server]`` section
372of ``buildout-zeo.conf``. Run `buildout` afterwards.
373
374The clients will listen on port 8081 and 8082. You can change settings
375in ``etc/zeo1.ini.in`` and ``etc/zeo2.ini.in`` respectively. Run
376buildout after any change.
377
378If you want to change the paster wrapper for any zeo client, you can
379edit ``etc/zeo1.conf`` and/or ``etc/zeo2.conf``. Run buildout
380afterwards.
381
382
[11405]383Stopping ZEO Servers and Clients
384================================
[11323]385
[11405]386Given everything was started in daemon mode, first stop the clients::
[11323]387
[11405]388  $ ./bin/zeo_client1 stop
389  $ ./bin/zeo_client2 stop
[11323]390
[11405]391Then stop the ZEO server::
392
393  $ ./bin/zeo_server stop
394
395
396Creating New ZEO Clients
397========================
398
399You want more ZEO clients to be created by `buildout`? Easy. Three
400steps are neccessary.
401
4021. Create config files in `etc/`
403--------------------------------
404
[11323]405Each client needs two configuration files:
406
407  - ``etc/zeoN.conf``
408       configuring the paster wrapper
409
410  - ``etc/zeoN.ini``
411       configuring the runtime config, ports, etc.
412
413Just copy over these files from the already existing zeo1/zeo2 files
414and replace ``zeo1`` or ``zeo2`` with your new name.
415
4162. Update buildout-zeo.cfg
417--------------------------
418
419Here, inside ``buildourt-zeo.cfg`` also three steps are needed.
420
421* 2.1. Create new .ini and .conf entries
422
423  The .conf and .ini files in etc/ are only templates that have to be
424  generated in their really used final location. In buildout-zeo.cfg
425  you can care for this by creating a new ``[zeoN_ini]`` and
426  ``[zeoN_conf]`` option (replacing ``N`` with a number, of course).
427
428  Just copy over existing entries and replace the mentions of ``zeo1``
429  or ``zeo2`` by your ``zeoN``.
430
431* 2.2. Create a new ``zeo_clientN`` entry
432
433  Then you have to create an entry that will generate the
434  ``zeo_clientN`` script. Again, just copy over an existing
435  ``[zeo_client1]`` entry and replace ``1`` withg your client number.
436
437* 2.3. Register the new sections in ``[buildout]`` section
438
439  When done with the above: add the new section in ``[buildout]``::
440
441    [buildout]
442      ...
443      <old entries...>
444      ...
445      zope_conf_zeo_5
446      zeo5_ini
447      zeo_client5
448
449  depending on how you named your new sections.
450
4513. Rerun ``buildout``
452---------------------
453
454When adding or removing client/server instances, make sure to stop all
455running servers/clients before rerunning buildout.
456
457To activate the new setup, rerun buildout::
458
459  $ bin/buildout -c buildout-zeo.cfg
460
461This should generate any new clients and remove older ones or just
462update configuration files.
463
464
465Considerations
466==============
467
468There are some things in the current buildout-zeo.cfg we might do not
469want. It extends the regular ``buildout.cfg`` so that we do not have
470to repeat most sections but the ``parts`` in ``[buildout]`` have to be
471listed.
472
473We need, however, not everything with a ZEO-deploy that is listed in a
474default buildout. We might do not need docs, no profiling, etc. Also a
475regular non-ZEO kofactl might not make to much sense. Therefore all
476this might be subject to changes.
[11381]477
478.. _Debian: http://www.debian.org/
479.. _Grok: http://grok.zope.org/
480.. _Python: http://www.python.org/
[11401]481.. _Subversion: http://subversion.apache.org/
[11381]482.. _Ubuntu: http://www.ubuntu.com/
483.. _virtualenv: http://www.virtualenv.org/en/latest/
484.. _WAeUP: https://www.waeup.org/
485.. _Zope: http://www.zope.org/
486.. _zc.buildout: http://cheeseshop.python.org/pypi/zc.buildout
[13690]487.. [#] Strictly speaking, this link fix is required by ``Pillow``, a
488   library used by Kofa to provide higher-level image processing.
Note: See TracBrowser for help on using the repository browser.