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

Last change on this file since 11912 was 11703, checked in by Henrik Bettermann, 10 years ago

Add missing colon.

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