source: main/waeup.aaua/trunk/INSTALL.txt @ 11382

Last change on this file since 11382 was 11382, checked in by uli, 11 years ago

Update virtualenv install section.

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