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

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

More about virtualenvs.

File size: 12.0 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
106After installing `virtualenv`_ you can install local sandboxes like
107this::
108
109  $ virtualenv --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. It is recommended to use a sandbox name that is short and at the
114same time reflects the Python version used (here: Python 2.7).
115
116By passing the ``no-site-packages`` switch we tell `virtualenv` to
117provide us a clean environment without any extra-packages installed
118systemwide. More recent versions of `virtualenv`_ have this option set
119by default.
120
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
125You now can activate the sandbox by doing::
126
127  $ source py27/bin/activate
128  (py27)$
129
130You will notice that the input prompt changes.
131
132To deactivate the sandbox at any time, enter::
133
134  (py27)$ deactivate
135
136and the prompt will be the same as before the activation.
137
138For the following steps make sure the sandbox is active.
139
140
141Creating a working place
142========================
143
144In the sandbox we now create our real working
145environment. To do this, we change to the sandbox and checkout the
146sources of Kofa from the subversion server::
147
148  (py27)$ cd mysandbox/
149  (py27)$ svn co https://svn.waeup.org/repos/main/waeup.kofa/trunk kofa-trunk
150
151where ``kofa-trunk`` is only a name we've chosen here to make clear
152where the sources come from. In this case we are installing the Kofa base
153package.
154
155The command should fetch the Kofa base package sources for you and
156put it in the directory ``kofa-trunk/``.
157
158Now enter the new directory::
159
160  (sandbox27)$ cd kofa-trunk
161
162
163You can run ``Kofa`` with a single client (useful for evaluation,
164development, etc.) or with multiple clients running in parallel. The
165latter setup is useful in productive environments with many thousands
166users. We will cover both setup types one after another.
167
168
169Part 1: Single Client Setup
170***************************
171
172Preparing the build
173===================
174
175In the sources directory (``kofa-trunk/``) you have to prepare the
176project to fetch needed components (eggs), compile C-code parts,
177etc. This steip will not touch any external projects::
178
179  (sandbox27)$ python bootstrap.py
180
181This will generate some directories and the ``buildout`` script in
182``bin/`` for us. This step must be executed only once for each
183instance.
184
185You can now deactivate the sandbox::
186
187  (sandbox27)$ deactivate
188
189Now we can do the real build by triggering::
190
191  $ bin/buildout
192
193If this is your first install of some Grok-related project, this step
194will need some time as lots of sources have to be fetched, many
195components must be compiled, etc.
196
197This step must be redone whenever you change something in
198``buildout.cfg`` or ``setup.py``.
199
200Note that if you have more than one sandbox for a Zope-based web
201application, it will probably make sense to share the eggs between the
202different sandboxes.  You can tell ``zc.buildout`` to use a central
203eggs directory by creating ``~/.buildout/default.cfg`` with the
204following contents::
205
206    [buildout]
207    eggs-directory = /home/bruno/buildout-eggs
208
209
210Start the instance
211==================
212
213You should be able now to start the created instance by doing::
214
215   $ bin/zopectl fg
216
217Alternatively you can do:
218
219    $ bin/paster serve parts/etc/deploy.ini
220
221The port numbers where Kofa is running on your server are defined in
222buildout.cfg under [kofa_params].
223
224If you now point a browser to the right port on your server, for example ::
225
226   localhost:8080
227
228you should get a login pop-up, where you can login as superuser with
229``grok`` and ``grok`` as username/password (Kofa base package only!).
230
231You can stop the instance by pressing <CTRL-C>.
232
233If you are connected and logged in,
234you should be able to add the grok-based applications
235(such as ``University``) from the menu.
236
237Add an instance of ``University`` and click on the link next to the
238then visible entry in the list of installed applications.
239
240Running the tests
241=================
242
243The tests are easily run by executing the test runner that's
244installed in the ``bin`` directory::
245
246    $ bin/test
247
248
249Part 2: Deploying Kofa as ZEO install
250*************************************
251
252Each ZEO install consists of at least one ZEO server and normally two
253or more ZEO clients. While the ZEO server is meant to manage the ZODB
254database for clients, the clients connect to the outside world, listen
255for request and do the real dataprocessing.
256
257We prepared a `buildout` configuration that sets up one server
258configuration and two client configs. This configuration is in
259``buildout-zeo.cfg``.
260
261Generating the ZEO setup
262========================
263
264To install Kofa ZEO-based you can run `buildout` with the given
265(or your own) configuration file like this::
266
267  $ ./bin/buildout -c buildout-zeo.cfg
268
269This should generate all scripts necessary to run servers, clients,
270etc.
271
272Starting ZEO servers and clients
273================================
274
275First start the server::
276
277  $ ./bin/zeo_server start
278
279Clients can be started by doing::
280
281  $ ./bin/zeo_client1 start
282  $ ./bin/zeo_client2 start
283
284This will start both clients in daemon mode.
285
286Instead of ``start`` you can, as usually, start an instance in
287foreground (``fg``), etc. You know the drill.
288
289
290Manually starting ZEO clients
291=============================
292
293This is normally not neccessary.
294
295``zeo_clientN`` scripts are basically wrappers around calls to
296``bin/paster``. You can bypass this wrapper and start a client
297'manually' like this::
298
299  $ ./bin/paster serve --pid-file var/zeo1.pid --daemon \
300        pars/etc/zeo1.ini
301
302It is important to give a pid-file as paster otherwise can not start
303different clients (they would all refer to the same pid file
304`paster.pid` and refuse to start after the first client was started).
305
306
307Setup (paramters, ports, etc.)
308==============================
309
310By default the server will listen on port 8100 for requests from
311localhost (not: from the outside world).
312
313You can change ZEO server settings in the ``[zeo_server]`` section
314of ``buildout-zeo.conf``. Run `buildout` afterwards.
315
316The clients will listen on port 8081 and 8082. You can change settings
317in ``etc/zeo1.ini.in`` and ``etc/zeo2.ini.in`` respectively. Run
318buildout after any change.
319
320If you want to change the paster wrapper for any zeo client, you can
321edit ``etc/zeo1.conf`` and/or ``etc/zeo2.conf``. Run buildout
322afterwards.
323
324
325Creating new clients
326====================
327
328You want more clients to be created by buildout? Easy. Three steps are
329neccessary.
330
3311. Create config files in etc/
332------------------------------
333
334Each client needs two configuration files:
335
336  - ``etc/zeoN.conf``
337       configuring the paster wrapper
338
339  - ``etc/zeoN.ini``
340       configuring the runtime config, ports, etc.
341
342Just copy over these files from the already existing zeo1/zeo2 files
343and replace ``zeo1`` or ``zeo2`` with your new name.
344
3452. Update buildout-zeo.cfg
346--------------------------
347
348Here, inside ``buildourt-zeo.cfg`` also three steps are needed.
349
350* 2.1. Create new .ini and .conf entries
351
352  The .conf and .ini files in etc/ are only templates that have to be
353  generated in their really used final location. In buildout-zeo.cfg
354  you can care for this by creating a new ``[zeoN_ini]`` and
355  ``[zeoN_conf]`` option (replacing ``N`` with a number, of course).
356
357  Just copy over existing entries and replace the mentions of ``zeo1``
358  or ``zeo2`` by your ``zeoN``.
359
360* 2.2. Create a new ``zeo_clientN`` entry
361
362  Then you have to create an entry that will generate the
363  ``zeo_clientN`` script. Again, just copy over an existing
364  ``[zeo_client1]`` entry and replace ``1`` withg your client number.
365
366* 2.3. Register the new sections in ``[buildout]`` section
367
368  When done with the above: add the new section in ``[buildout]``::
369
370    [buildout]
371      ...
372      <old entries...>
373      ...
374      zope_conf_zeo_5
375      zeo5_ini
376      zeo_client5
377
378  depending on how you named your new sections.
379
3803. Rerun ``buildout``
381---------------------
382
383When adding or removing client/server instances, make sure to stop all
384running servers/clients before rerunning buildout.
385
386To activate the new setup, rerun buildout::
387
388  $ bin/buildout -c buildout-zeo.cfg
389
390This should generate any new clients and remove older ones or just
391update configuration files.
392
393
394Considerations
395==============
396
397There are some things in the current buildout-zeo.cfg we might do not
398want. It extends the regular ``buildout.cfg`` so that we do not have
399to repeat most sections but the ``parts`` in ``[buildout]`` have to be
400listed.
401
402We need, however, not everything with a ZEO-deploy that is listed in a
403default buildout. We might do not need docs, no profiling, etc. Also a
404regular non-ZEO kofactl might not make to much sense. Therefore all
405this might be subject to changes.
406
407.. _Debian: http://www.debian.org/
408.. _Grok: http://grok.zope.org/
409.. _Python: http://www.python.org/
410.. _Ubuntu: http://www.ubuntu.com/
411.. _virtualenv: http://www.virtualenv.org/en/latest/
412.. _WAeUP: https://www.waeup.org/
413.. _Zope: http://www.zope.org/
414.. _zc.buildout: http://cheeseshop.python.org/pypi/zc.buildout
Note: See TracBrowser for help on using the repository browser.