source: main/waeup.kofa/branches/uli-upgrade-beaker/docs/INSTALL.txt @ 17182

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

Update install instructions.

File size: 16.5 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
20
21Quick Install on Ubuntu 18.04
22*****************************
23
24If you want to install Kofa on a running Ubuntu system, the following quick
25steps might be sufficient::
26
27  ## install neccessary system packages as superuser
28  $ sudo apt-get update && apt-get install -y  # update system
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
30
31  ## get sources as regular user
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
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
63Prerequisites
64*************
65
66The Kofa packages are based on `Grok`_, which is a Python_
67framework for agile web application development. Grok_ itself is based
68on `Zope`_.
69
70Both, Grok_ and Zope_, are written in the `Python`_ programming
71language (with parts written in C). You therefore have to have
72`Python`_ installed (including `Python`_ headers) in version 2.7
73(Python 3.x is currently not supported).
74
75
76Preparing the System
77====================
78
79For a Kofa install we need of course `Python`_ installed as well as
80some standard developer tools like C compilers, C libraries, etc.
81
82What you need (Debian/Ubuntu package names in brackets):
83
84* Python 2.7 (``python2.7``)
85
86* Python 2.7 development files (``python2.7-dev``)
87
88* A C-Compiler with basic C developer libraries (``build-essential``)
89
90* A subversion client (``subversion``)
91
92* XML and XSLT development libraries (``libxml2-dev``, ``libxslt1-dev``)
93
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
98* enscript (``enscript``) [optional]
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
104  $ sudo apt-get install python2.7 python2.7-dev subversion \
105                         build-essential enscript libxml2-dev libxslt1-dev \
106                         zlib1g-dev libssl-dev libffi-dev libjpeg-dev \
107                         libfreetype6-dev libtiff-dev libopenjpeg-dev
108
109Afterwards you should be able to enter::
110
111  $ python2.7
112
113at the commandline and get a Python_ prompt. Quit the interpreter
114pressing <CTRL-D>.
115
116The above packages have been tested to be sufficient for running Kofa
117on Ubuntu. We check this with Docker images created at
118
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
131Installing `virtualenv`
132=======================
133
134We strongly suggest use of `virtualenv`_ to create Python_ sandboxes
135where you can run your code without touching any other installations.
136
137`virtualenv`_ is also the only possibility to build a Kofa install
138without the need of superuser permissions. In short: `virtualenv`_
139will make your life easier. Use it.
140
141Detailed install instructions for `virtualenv`_ can be found on
142http://www.virtualenv.org/en/latest/virtualenv.html#installation.
143
144The short way for a user install (no superuser perms required) is like
145this::
146
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
151
152Superusers can install `virtualenv`_ system-wide much easier. On
153`Debian`_/`Ubuntu`_ systems where you have superuser permissions, you
154can install `virtualenv`_ via::
155
156  $ sudo apt-get install python-virtualenv
157
158*Or*, they install if `pip` first::
159
160  $ sudo apt-get install python-pip
161
162and then use `pip` to install `virtualenv`_::
163
164  $ sudo pip install virtualenv
165
166
167Creating a Sandbox
168==================
169
170After installing `virtualenv`_ you can install local sandboxes like
171this (if `virtualenv` is installed system-wide)::
172
173  $ virtualenv --no-site-packages py27
174
175*or* like this::
176
177  $ python /path/to/my/virtualenv.py --no-site-packages py27
178
179where ``py27`` is a directory in the filesystem where your sandbox
180will be created. `virtualenv` will also create this directory for
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).
184
185By passing the ``no-site-packages`` switch we tell `virtualenv` to
186provide a clean environment without any extra-packages installed
187systemwide. More recent versions of `virtualenv`_ have this option set
188by default.
189
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
194You now can activate the sandbox by doing::
195
196  $ source py27/bin/activate
197  (py27)$
198
199You will notice that the input prompt changes, indicating the name of
200the sandbox activated.
201
202To deactivate the sandbox at any time, enter::
203
204  (py27)$ deactivate
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
211Getting the Sources
212===================
213
214Now, as the sandbox is activated (see above, if not), we can fetch the
215sources for Kofa.
216
217Source from PyPI
218----------------
219
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
228  (py27)$ wget https://pypi.python.org/packages/source/w/waeup.kofa/waeup.kofa-1.5.tar.gz
229
230where ``1.5`` is, of course, only one possible version.
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
241  (py27)$ svn co https://svn.waeup.org/repos/main/waeup.kofa/trunk
242
243The command should fetch the Kofa base package sources for you and
244will put everything in a new directory ``trunk/``.
245
246Now enter the new directory::
247
248  (py27)$ cd trunk/
249
250and you can start building the real package.
251
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::
257
258            (py27)$ svn co https://svn.waeup.org/repos/main/<PKG-NAME>/trunk
259
260          For the exact link, please refer to the README.txt file in
261          your package.
262
263
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
277interfering with other packages installed on your server::
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
288Part 1: Single Client Setup
289***************************
290
291You can run Kofa with a single client (useful for evaluation,
292development, etc.) or with multiple clients running in parallel. The
293latter setup is useful in productive environments with many thousands
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`_.
297
298
299Building the Package
300====================
301
302In the sources directory (``trunk/``) you have to prepare the
303project to fetch needed components (eggs), compile C-code parts,
304etc. This is done by a single command ``buildout``::
305
306  $ ./bin/buildout
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
313``buildout.cfg``, ``buildout-zeo.cfg``, or ``setup.py``.
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
321  [buildout]
322  eggs-directory = /home/bruno/buildout-eggs
323
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).
327
328
329Start the Instance
330==================
331
332You should be able now to start the created instance by doing::
333
334  $ ./bin/kofactl fg
335
336Alternatively you can do::
337
338  $ bin/paster serve parts/etc/deploy-themed.ini
339
340The port numbers where Kofa is running on your server are defined in
341`buildout.cfg` under ``[kofa_params]``.
342
343If you now point a browser to the right port on your server, for example::
344
345  localhost:8080
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
359Running the Tests
360=================
361
362All WAeUP_ packages come with comprehensive test suites ensuring the
363software quality also after changes and updates.
364
365The package tests are easily run by executing the test runner
366from the ``bin`` directory::
367
368  $ ./bin/test
369
370Use the ``-c`` option to get coloured output. Use the ``--pdb`` option
371to start the Python_ debugger when a test fails.
372
373
374Part 2: ZEO Install
375*******************
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
386Generating the ZEO Setup
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
397Starting ZEO Servers and Clients
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
415Manually Starting ZEO Clients
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
427It is important to give a pid-file as `paster` otherwise can not start
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
432Setup (parameters, ports, etc.)
433===============================
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
450Stopping ZEO Servers and Clients
451================================
452
453Given everything was started in daemon mode, first stop the clients::
454
455  $ ./bin/zeo_client1 stop
456  $ ./bin/zeo_client2 stop
457
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
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.
544
545.. _Debian: http://www.debian.org/
546.. _Grok: http://grok.zope.org/
547.. _Python: http://www.python.org/
548.. _Subversion: http://subversion.apache.org/
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
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.