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

Last change on this file since 16250 was 15892, checked in by Henrik Bettermann, 5 years ago

Update install instructions.

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