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

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

Fix :pyobject: option.

File size: 14.6 KB
Line 
1Installation of Kofa
2####################
3
4These are generic installation instructions for the WAeUP_ Kofa
5student information portal and customized versions thereof.
6
7For specific aspects of this package please refer to the local README
8file.
9
10Please note, that **only Linux-based installs** are described and actively
11supported. We recommend use of Debian_ / Ubuntu_.
12
13.. note:: This means we do not actively support Windows(tm)!
14
15.. contents:: Table of Contents
16   :local:
17
18.. _prerequisites:
19
20Prerequisites
21*************
22
23The Kofa packages are based on `Grok`_, which is a Python_
24framework for agile web application development. Grok_ itself is based
25on `Zope`_.
26
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).
30
31
32Preparing the System
33====================
34
35For a Kofa install we need of course `Python`_ installed as well as
36some standard developer tools like C compilers, C libraries, etc.
37
38What you need (Debian/Ubuntu package names in brackets):
39
40* Python 2.7 (``python2.7``)
41
42* Python 2.7 development files (``python2.7-dev``)
43
44* A C-Compiler with basic C developer libraries (``build-essential``)
45
46* A subversion client (``subversion``)
47
48* XML and XSLT development libraries (``libxml2-dev``, ``libxslt1-dev``)
49
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
54* enscript (``enscript``) [optional]
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
60  $ sudo apt-get install python2.7 python2.7-dev subversion \
61                         build-essential enscript libxml2-dev libxslt1-dev \
62                         zlib1g-dev libssl-dev libffi-dev libjpeg-dev \
63                         libfreetype6-dev libtiff-dev libopenjpeg-dev
64
65Afterwards you should be able to enter::
66
67  $ python2.7
68
69at the commandline and get a Python_ prompt. Quit the interpreter
70pressing <CTRL-D>.
71
72The above packages have been tested to be sufficient for running Kofa
73on Ubuntu 14.04. We check this with Docker images created at
74
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
87Installing `virtualenv`
88=======================
89
90We strongly suggest use of `virtualenv`_ to create Python_ sandboxes
91where you can run your code without touching any other installations.
92
93`virtualenv`_ is also the only possibility to build a Kofa install
94without the need of superuser permissions. In short: `virtualenv`_
95will make your life easier. Use it.
96
97Detailed install instructions for `virtualenv`_ can be found on
98http://www.virtualenv.org/en/latest/virtualenv.html#installation.
99
100The short way for a user install (no superuser perms required) is like
101this::
102
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
107
108Superusers can install `virtualenv`_ system-wide much easier. On
109`Debian`_/`Ubuntu`_ systems where you have superuser permissions, you
110can install `virtualenv`_ via::
111
112  $ sudo apt-get install python-virtualenv
113
114*Or*, if `pip` is installed already (superusers can install it via
115 ``sudo apt-get install python-pip`` on `Debian`_/`Ubuntu`_)::
116
117  $ sudo pip install virtualenv
118
119
120Creating a Sandbox
121==================
122
123After installing `virtualenv`_ you can install local sandboxes like
124this (if `virtualenv` is installed system-wide)::
125
126  $ virtualenv --no-site-packages py27
127
128*or* like this::
129
130  $ python /path/to/my/virtualenv.py --no-site-packages py27
131
132where ``py27`` is a directory in the filesystem where your sandbox
133will be created. `virtualenv` will also create this directory for
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).
137
138By passing the ``no-site-packages`` switch we tell `virtualenv` to
139provide a clean environment without any extra-packages installed
140systemwide. More recent versions of `virtualenv`_ have this option set
141by default.
142
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
147You now can activate the sandbox by doing::
148
149  $ source py27/bin/activate
150  (py27)$
151
152You will notice that the input prompt changes, indicating the name of
153the sandbox activated.
154
155To deactivate the sandbox at any time, enter::
156
157  (py27)$ deactivate
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
164Getting the Sources
165===================
166
167Now, as the sandbox is activated (see above, if not), we can fetch the
168sources for Kofa.
169
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::
173
174  (py27)$ svn co https://svn.waeup.org/repos/main/waeup.kofa/trunk
175
176The command should fetch the Kofa base package sources for you and
177will put everything in a new directory ``trunk/``.
178
179Now enter the new directory::
180
181  (py27)$ cd trunk/
182
183and you can start building the real package.
184
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::
190
191            (py27)$ svn co https://svn.waeup.org/repos/main/<PKG-NAME>/trunk
192
193          For the exact link, please refer to the README.txt file in
194          your package.
195
196
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
210interfering with other packages installed on your server::
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
221Part 1: Single Client Setup
222***************************
223
224You can run Kofa with a single client (useful for evaluation,
225development, etc.) or with multiple clients running in parallel. The
226latter setup is useful in productive environments with many thousands
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`_.
230
231
232Building the Package
233====================
234
235In the sources directory (``trunk/``) you have to prepare the
236project to fetch needed components (eggs), compile C-code parts,
237etc. This is done by a single command ``buildout``::
238
239  $ ./bin/buildout
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
246``buildout.cfg``, ``buildout-zeo.cfg``, or ``setup.py``.
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
254  [buildout]
255  eggs-directory = /home/bruno/buildout-eggs
256
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).
260
261
262Start the Instance
263==================
264
265You should be able now to start the created instance by doing::
266
267  $ ./bin/kofactl fg
268
269Alternatively you can do::
270
271  $ bin/paster serve parts/etc/deploy-themed.ini
272
273The port numbers where Kofa is running on your server are defined in
274`buildout.cfg` under ``[kofa_params]``.
275
276If you now point a browser to the right port on your server, for example::
277
278  localhost:8080
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
292Running the Tests
293=================
294
295All WAeUP_ packages come with comprehensive test suites ensuring the
296software quality also after changes and updates.
297
298The package tests are easily run by executing the test runner
299from the ``bin`` directory::
300
301  $ ./bin/test
302
303Use the ``-c`` option to get coloured output. Use the ``--pdb`` option
304to start the Python_ debugger when a test fails.
305
306
307Part 2: ZEO Install
308*******************
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
319Generating the ZEO Setup
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
330Starting ZEO Servers and Clients
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
348Manually Starting ZEO Clients
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
360It is important to give a pid-file as `paster` otherwise can not start
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
365Setup (parameters, ports, etc.)
366===============================
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
383Stopping ZEO Servers and Clients
384================================
385
386Given everything was started in daemon mode, first stop the clients::
387
388  $ ./bin/zeo_client1 stop
389  $ ./bin/zeo_client2 stop
390
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
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.
477
478.. _Debian: http://www.debian.org/
479.. _Grok: http://grok.zope.org/
480.. _Python: http://www.python.org/
481.. _Subversion: http://subversion.apache.org/
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
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.