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

Last change on this file since 13629 was 13270, checked in by uli, 9 years ago

Fix typo.

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