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

Last change on this file since 13826 was 13826, checked in by Henrik Bettermann, 8 years ago

This looks better.

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*, they install if `pip` first::
115
116  $ sudo apt-get install python-pip
117
118and then use `pip` to install `virtualenv`_::
119
120  $ sudo pip install virtualenv
121
122
123Creating a Sandbox
124==================
125
126After installing `virtualenv`_ you can install local sandboxes like
127this (if `virtualenv` is installed system-wide)::
128
129  $ virtualenv --no-site-packages py27
130
131*or* like this::
132
133  $ python /path/to/my/virtualenv.py --no-site-packages py27
134
135where ``py27`` is a directory in the filesystem where your sandbox
136will be created. `virtualenv` will also create this directory for
137you. While you can pick any sandbox name you want, it is recommended
138to use a sandbox name that is short and at the same time reflects the
139Python version used (here: Python 2.7).
140
141By passing the ``no-site-packages`` switch we tell `virtualenv` to
142provide a clean environment without any extra-packages installed
143systemwide. More recent versions of `virtualenv`_ have this option set
144by default.
145
146Another often used option of `virtualenv`_ is ``-p``. With ``-p`` you
147can tell `virtualenv`_ which Python executable to use as base for the
148new sandbox.
149
150You now can activate the sandbox by doing::
151
152  $ source py27/bin/activate
153  (py27)$
154
155You will notice that the input prompt changes, indicating the name of
156the sandbox activated.
157
158To deactivate the sandbox at any time, enter::
159
160  (py27)$ deactivate
161
162and the prompt will be the same as before the activation.
163
164For the following steps make sure the sandbox is active.
165
166
167Getting the Sources
168===================
169
170Now, as the sandbox is activated (see above, if not), we can fetch the
171sources for Kofa.
172
173As Kofa is currently available from the Subversion_ repository only,
174we use the Subversion_ client `svn` and checkout the main devel branch
175of the `waeup.kofa` package like this::
176
177  (py27)$ svn co https://svn.waeup.org/repos/main/waeup.kofa/trunk
178
179The command should fetch the Kofa base package sources for you and
180will put everything in a new directory ``trunk/``.
181
182Now enter the new directory::
183
184  (py27)$ cd trunk/
185
186and you can start building the real package.
187
188.. note:: If you not want to work with the `waeup.kofa` package but a
189          customized package (like ``waeup.aaue`` or similar), then
190          you can use the above checkout command but with
191          ``waeup.kofa`` replaced by the name of the customized
192          package::
193
194            (py27)$ svn co https://svn.waeup.org/repos/main/<PKG-NAME>/trunk
195
196          For the exact link, please refer to the README.txt file in
197          your package.
198
199
200Bootstrapping the Build
201=======================
202
203After `Creating a Sandbox`_ and `Getting the Sources`_ we have to
204initialize the newly created development environment::
205
206  (py27)$ python bootstrap.py
207
208This should create a local ``bin/`` directory with at least a script
209``buildout`` in it.
210
211If bootstrapping fails, chances are, that you need the `distribute`
212package installed. In a virtual environment you can install it without
213interfering with other packages installed on your server::
214
215  (py27)$ pip install --upgrade distribute
216
217Afterwards you have to retry the bootstrapping, until you get a
218working ``buildout`` script in the local ``bin/`` directory.
219
220Once the ``buildout`` script exists, you do not have to activate the
221virtual envronment any more (although you can).
222
223
224Part 1: Single Client Setup
225***************************
226
227You can run Kofa with a single client (useful for evaluation,
228development, etc.) or with multiple clients running in parallel. The
229latter setup is useful in productive environments with many thousands
230users and called a ``ZEO`` install. We will cover both setup
231types. The first is covered here, the latter one is covered in `Part
2322: ZEO Install`_.
233
234
235Building the Package
236====================
237
238In the sources directory (``trunk/``) you have to prepare the
239project to fetch needed components (eggs), compile C-code parts,
240etc. This is done by a single command ``buildout``::
241
242  $ ./bin/buildout
243
244If this is your first install of some Grok-related project, this step
245will need some time as lots of sources have to be fetched, many
246components must be compiled, etc.
247
248This step must be redone whenever you change something in
249``buildout.cfg``, ``buildout-zeo.cfg``, or ``setup.py``.
250
251Note that if you have more than one sandbox for a Zope-based web
252application, it will probably make sense to share the eggs between the
253different sandboxes.  You can tell ``zc.buildout`` to use a central
254eggs directory by creating ``~/.buildout/default.cfg`` with the
255following contents::
256
257  [buildout]
258  eggs-directory = /home/bruno/buildout-eggs
259
260where the given directory should be exist beforehand. All eggs of all
261`buildout` projects will then be stored in this directory (and not
262fetched anew if already existing there).
263
264
265Start the Instance
266==================
267
268You should be able now to start the created instance by doing::
269
270  $ ./bin/kofactl fg
271
272Alternatively you can do::
273
274  $ bin/paster serve parts/etc/deploy-themed.ini
275
276The port numbers where Kofa is running on your server are defined in
277`buildout.cfg` under ``[kofa_params]``.
278
279If you now point a browser to the right port on your server, for example::
280
281  localhost:8080
282
283you should get a login pop-up, where you can login as superuser with
284``grok`` and ``grok`` as username/password (Kofa base package only!).
285
286You can stop the instance by pressing <CTRL-C>.
287
288If you are connected and logged in,
289you should be able to add the grok-based applications
290(such as ``University``) from the menu.
291
292Add an instance of ``University`` and click on the link next to the
293then visible entry in the list of installed applications.
294
295Running the Tests
296=================
297
298All WAeUP_ packages come with comprehensive test suites ensuring the
299software quality also after changes and updates.
300
301The package tests are easily run by executing the test runner
302from the ``bin`` directory::
303
304  $ ./bin/test
305
306Use the ``-c`` option to get coloured output. Use the ``--pdb`` option
307to start the Python_ debugger when a test fails.
308
309
310Part 2: ZEO Install
311*******************
312
313Each ZEO install consists of at least one ZEO server and normally two
314or more ZEO clients. While the ZEO server is meant to manage the ZODB
315database for clients, the clients connect to the outside world, listen
316for request and do the real dataprocessing.
317
318We prepared a `buildout` configuration that sets up one server
319configuration and two client configs. This configuration is in
320``buildout-zeo.cfg``.
321
322Generating the ZEO Setup
323========================
324
325To install Kofa ZEO-based you can run `buildout` with the given
326(or your own) configuration file like this::
327
328  $ ./bin/buildout -c buildout-zeo.cfg
329
330This should generate all scripts necessary to run servers, clients,
331etc.
332
333Starting ZEO Servers and Clients
334================================
335
336First start the server::
337
338  $ ./bin/zeo_server start
339
340Clients can be started by doing::
341
342  $ ./bin/zeo_client1 start
343  $ ./bin/zeo_client2 start
344
345This will start both clients in daemon mode.
346
347Instead of ``start`` you can, as usually, start an instance in
348foreground (``fg``), etc. You know the drill.
349
350
351Manually Starting ZEO Clients
352=============================
353
354This is normally not neccessary.
355
356``zeo_clientN`` scripts are basically wrappers around calls to
357``bin/paster``. You can bypass this wrapper and start a client
358'manually' like this::
359
360  $ ./bin/paster serve --pid-file var/zeo1.pid --daemon \
361        pars/etc/zeo1.ini
362
363It is important to give a pid-file as `paster` otherwise can not start
364different clients (they would all refer to the same pid file
365`paster.pid` and refuse to start after the first client was started).
366
367
368Setup (parameters, ports, etc.)
369===============================
370
371By default the server will listen on port 8100 for requests from
372localhost (not: from the outside world).
373
374You can change ZEO server settings in the ``[zeo_server]`` section
375of ``buildout-zeo.conf``. Run `buildout` afterwards.
376
377The clients will listen on port 8081 and 8082. You can change settings
378in ``etc/zeo1.ini.in`` and ``etc/zeo2.ini.in`` respectively. Run
379buildout after any change.
380
381If you want to change the paster wrapper for any zeo client, you can
382edit ``etc/zeo1.conf`` and/or ``etc/zeo2.conf``. Run buildout
383afterwards.
384
385
386Stopping ZEO Servers and Clients
387================================
388
389Given everything was started in daemon mode, first stop the clients::
390
391  $ ./bin/zeo_client1 stop
392  $ ./bin/zeo_client2 stop
393
394Then stop the ZEO server::
395
396  $ ./bin/zeo_server stop
397
398
399Creating New ZEO Clients
400========================
401
402You want more ZEO clients to be created by `buildout`? Easy. Three
403steps are neccessary.
404
4051. Create config files in `etc/`
406--------------------------------
407
408Each client needs two configuration files:
409
410  - ``etc/zeoN.conf``
411       configuring the paster wrapper
412
413  - ``etc/zeoN.ini``
414       configuring the runtime config, ports, etc.
415
416Just copy over these files from the already existing zeo1/zeo2 files
417and replace ``zeo1`` or ``zeo2`` with your new name.
418
4192. Update buildout-zeo.cfg
420--------------------------
421
422Here, inside ``buildourt-zeo.cfg`` also three steps are needed.
423
424* 2.1. Create new .ini and .conf entries
425
426  The .conf and .ini files in etc/ are only templates that have to be
427  generated in their really used final location. In buildout-zeo.cfg
428  you can care for this by creating a new ``[zeoN_ini]`` and
429  ``[zeoN_conf]`` option (replacing ``N`` with a number, of course).
430
431  Just copy over existing entries and replace the mentions of ``zeo1``
432  or ``zeo2`` by your ``zeoN``.
433
434* 2.2. Create a new ``zeo_clientN`` entry
435
436  Then you have to create an entry that will generate the
437  ``zeo_clientN`` script. Again, just copy over an existing
438  ``[zeo_client1]`` entry and replace ``1`` withg your client number.
439
440* 2.3. Register the new sections in ``[buildout]`` section
441
442  When done with the above: add the new section in ``[buildout]``::
443
444    [buildout]
445      ...
446      <old entries...>
447      ...
448      zope_conf_zeo_5
449      zeo5_ini
450      zeo_client5
451
452  depending on how you named your new sections.
453
4543. Rerun ``buildout``
455---------------------
456
457When adding or removing client/server instances, make sure to stop all
458running servers/clients before rerunning buildout.
459
460To activate the new setup, rerun buildout::
461
462  $ bin/buildout -c buildout-zeo.cfg
463
464This should generate any new clients and remove older ones or just
465update configuration files.
466
467
468Considerations
469==============
470
471There are some things in the current buildout-zeo.cfg we might do not
472want. It extends the regular ``buildout.cfg`` so that we do not have
473to repeat most sections but the ``parts`` in ``[buildout]`` have to be
474listed.
475
476We need, however, not everything with a ZEO-deploy that is listed in a
477default buildout. We might do not need docs, no profiling, etc. Also a
478regular non-ZEO kofactl might not make to much sense. Therefore all
479this might be subject to changes.
480
481.. _Debian: http://www.debian.org/
482.. _Grok: http://grok.zope.org/
483.. _Python: http://www.python.org/
484.. _Subversion: http://subversion.apache.org/
485.. _Ubuntu: http://www.ubuntu.com/
486.. _virtualenv: http://www.virtualenv.org/en/latest/
487.. _WAeUP: https://www.waeup.org/
488.. _Zope: http://www.zope.org/
489.. _zc.buildout: http://cheeseshop.python.org/pypi/zc.buildout
490.. [#] Strictly speaking, this link fix is required by ``Pillow``, a
491   library used by Kofa to provide higher-level image processing.
Note: See TracBrowser for help on using the repository browser.