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

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

Do not format the term 'Kofa'.

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