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

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

Add bootstrapping section.

File size: 13.2 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::
16
17
18Prerequisites
19*************
20
21The Kofa packages are based on `Grok`_, which is a Python_
22framework for agile webapplication development. Grok_ itself is based
23on `Zope`_.
24
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).
28
29
30Preparing the System
31====================
32
33For a `Kofa` install we need of course `Python`_ installed as well as
34some standard developer tools like C compilers, C libraries, etc.
35
36What you need (Debian/Ubuntu package names in brackets):
37
38* Python 2.7 (``python2.7``)
39
40* Python 2.7 development files (``python2.7-dev``)
41
42* A C-Compiler with basic C developer libraries (``build-essential``)
43
44* A subversion client (``svn``)
45
46* enscript (``enscript``) [optional]
47
48  This is only needed if you want test coverage reports.
49
50All these packages can be installed on Debian systems like this::
51
52  $ sudo apt-get install python2.7 python2.7-dev svn \
53                         build-essential enscript
54
55Afterwards you should be able to enter::
56
57  $ python2.7
58
59at the commandline and get a Python_ prompt. Quit the interpreter
60pressing <CTRL-D>.
61
62
63Installing `virtualenv`
64=======================
65
66We strongly suggest use of `virtualenv`_ to create Python_ sandboxes
67where you can run your code without touching any other installations.
68
69`virtualenv`_ is also the only possibility to build a `Kofa` install
70without the need of superuser permissions. In short: `virtualenv`_
71will make your life easier. Use it.
72
73Detailed install instructions for `virtualenv`_ can be found on
74http://www.virtualenv.org/en/latest/virtualenv.html#installation.
75
76The short way for a user install (no superuser perms required) is like
77this::
78
79  $ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.4.tar.gz#md5=9accc2d3f0ec1da479ce2c3d1fdff06e
80  $ tar xvfz virtualenv-1.11.4.tar.gz
81  $ cd virtualenv-1.11.4
82  $ python virtualenv.py py27
83
84Superusers can install `virtualenv`_ system-wide much easier. On
85`Debian`_/`Ubuntu`_ systems where you have superuser permissions, you
86can install `virtualenv`_ via::
87
88  $ sudo apt-get install python-virtualenv
89
90*Or*, if `pip` is installed already (superusers can install it via
91 ``sudo apt-get install python-pip`` on `Debian`_/`Ubuntu`_)::
92
93  $ sudo pip install virtualenv
94
95
96Creating a Sandbox
97==================
98
99After installing `virtualenv`_ you can install local sandboxes like
100this (if `virtualenv` is installed system-wide)::
101
102  $ virtualenv --no-site-packages py27
103
104*or* like this::
105
106  $ python /path/to/my/virtualenv.py --no-site-packages py27
107
108where ``py27`` is a directory in the filesystem where your sandbox
109will be created. `virtualenv` will also create this directory for
110you. While you can pick any sandbox name you want, it is recommended
111to use a sandbox name that is short and at the same time reflects the
112Python version used (here: Python 2.7).
113
114By passing the ``no-site-packages`` switch we tell `virtualenv` to
115provide a clean environment without any extra-packages installed
116systemwide. More recent versions of `virtualenv`_ have this option set
117by default.
118
119Another often used option of `virtualenv`_ is ``-p``. With ``-p`` you
120can tell `virtualenv`_ which Python executable to use as base for the
121new sandbox.
122
123You now can activate the sandbox by doing::
124
125  $ source py27/bin/activate
126  (py27)$
127
128You will notice that the input prompt changes, indicating the name of
129the sandbox activated.
130
131To deactivate the sandbox at any time, enter::
132
133  (py27)$ deactivate
134
135and the prompt will be the same as before the activation.
136
137For the following steps make sure the sandbox is active.
138
139
140Getting the Sources
141===================
142
143Now, as the sandbox is activated (see above, if not), we can fetch the
144sources for Kofa.
145
146As Kofa is currently available from the Subversion_ repository only,
147we use the Subversion_ client `svn` and checkout the main devel branch
148of the `waeup.kofa` package like this::
149
150  (py27)$ svn co https://svn.waeup.org/repos/main/waeup.kofa/trunk
151
152The command should fetch the Kofa base package sources for you and
153will put everything in a new directory ``trunk/``.
154
155Now enter the new directory::
156
157  (py27)$ cd trunk/
158
159and you can start building the real package.
160
161.. note:: If you not want to work with the `waeup.kofa` package but a
162          customized package (like ``waeup.aaue`` or similar), then
163          you can use the above checkout command but with
164          ``waeup.kofa`` replaced by the name of the customized
165          package::
166
167            (py27)$ svn co https://svn.waeup.org/repos/main/<PKG-NAME>/trunk
168
169          For the exact link, please refer to the README.txt file in
170          your package.
171
172
173Bootstrapping the Build
174=======================
175
176After `Creating a Sandbox`_ and `Getting the Sources`_ we have to
177initialize the newly created development environment::
178
179  (py27)$ python bootstrap.py
180
181This should create a local ``bin/`` directory with at least a script
182``buildout`` in it.
183
184If bootstrapping fails, chances are, that you need the `distribute`
185package installed. In a virtual environment you can install it without
186interfering with other packages installed on your server:
187
188  (py27)$ pip install --upgrade distribute
189
190Afterwards you have to retry the bootstrapping, until you get a
191working ``buildout`` script in the local ``bin/`` directory.
192
193Once the ``buildout`` script exists, you do not have to activate the
194virtual envronment any more (although you can).
195
196
197Part 1: Single Client Setup
198***************************
199
200You can run ``Kofa`` with a single client (useful for evaluation,
201development, etc.) or with multiple clients running in parallel. The
202latter setup is useful in productive environments with many thousands
203users and called a ``ZEO`` install. We will cover both setup
204types. The first is covered here, the latter one is covered in `Part
2052: ZEO Install`_.
206
207
208Preparing the build
209===================
210
211In the sources directory (``kofa-trunk/``) you have to prepare the
212project to fetch needed components (eggs), compile C-code parts,
213etc. This steip will not touch any external projects::
214
215  (py27)$ python bootstrap.py
216
217This will generate some directories and the ``buildout`` script in
218``bin/`` for us. This step must be executed only once for each
219instance.
220
221You can now deactivate the sandbox::
222
223  (py27)$ deactivate
224
225Now we can do the real build by triggering::
226
227  $ bin/buildout
228
229If this is your first install of some Grok-related project, this step
230will need some time as lots of sources have to be fetched, many
231components must be compiled, etc.
232
233This step must be redone whenever you change something in
234``buildout.cfg`` or ``setup.py``.
235
236Note that if you have more than one sandbox for a Zope-based web
237application, it will probably make sense to share the eggs between the
238different sandboxes.  You can tell ``zc.buildout`` to use a central
239eggs directory by creating ``~/.buildout/default.cfg`` with the
240following contents::
241
242  [buildout]
243  eggs-directory = /home/bruno/buildout-eggs
244
245
246Start the instance
247==================
248
249You should be able now to start the created instance by doing::
250
251  $ bin/zopectl fg
252
253Alternatively you can do::
254
255  $ bin/paster serve parts/etc/deploy.ini
256
257The port numbers where Kofa is running on your server are defined in
258buildout.cfg under [kofa_params].
259
260If you now point a browser to the right port on your server, for example ::
261
262  localhost:8080
263
264you should get a login pop-up, where you can login as superuser with
265``grok`` and ``grok`` as username/password (Kofa base package only!).
266
267You can stop the instance by pressing <CTRL-C>.
268
269If you are connected and logged in,
270you should be able to add the grok-based applications
271(such as ``University``) from the menu.
272
273Add an instance of ``University`` and click on the link next to the
274then visible entry in the list of installed applications.
275
276Running the tests
277=================
278
279The tests are easily run by executing the test runner that's
280installed in the ``bin`` directory::
281
282  $ bin/test
283
284
285Part 2: ZEO Install
286*******************
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
297Generating the ZEO setup
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
308Starting ZEO servers and clients
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
326Manually starting ZEO clients
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
338It is important to give a pid-file as paster otherwise can not start
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
361Creating new clients
362====================
363
364You want more clients to be created by buildout? Easy. Three steps are
365neccessary.
366
3671. Create config files in etc/
368------------------------------
369
370Each client needs two configuration files:
371
372  - ``etc/zeoN.conf``
373       configuring the paster wrapper
374
375  - ``etc/zeoN.ini``
376       configuring the runtime config, ports, etc.
377
378Just copy over these files from the already existing zeo1/zeo2 files
379and replace ``zeo1`` or ``zeo2`` with your new name.
380
3812. Update buildout-zeo.cfg
382--------------------------
383
384Here, inside ``buildourt-zeo.cfg`` also three steps are needed.
385
386* 2.1. Create new .ini and .conf entries
387
388  The .conf and .ini files in etc/ are only templates that have to be
389  generated in their really used final location. In buildout-zeo.cfg
390  you can care for this by creating a new ``[zeoN_ini]`` and
391  ``[zeoN_conf]`` option (replacing ``N`` with a number, of course).
392
393  Just copy over existing entries and replace the mentions of ``zeo1``
394  or ``zeo2`` by your ``zeoN``.
395
396* 2.2. Create a new ``zeo_clientN`` entry
397
398  Then you have to create an entry that will generate the
399  ``zeo_clientN`` script. Again, just copy over an existing
400  ``[zeo_client1]`` entry and replace ``1`` withg your client number.
401
402* 2.3. Register the new sections in ``[buildout]`` section
403
404  When done with the above: add the new section in ``[buildout]``::
405
406    [buildout]
407      ...
408      <old entries...>
409      ...
410      zope_conf_zeo_5
411      zeo5_ini
412      zeo_client5
413
414  depending on how you named your new sections.
415
4163. Rerun ``buildout``
417---------------------
418
419When adding or removing client/server instances, make sure to stop all
420running servers/clients before rerunning buildout.
421
422To activate the new setup, rerun buildout::
423
424  $ bin/buildout -c buildout-zeo.cfg
425
426This should generate any new clients and remove older ones or just
427update configuration files.
428
429
430Considerations
431==============
432
433There are some things in the current buildout-zeo.cfg we might do not
434want. It extends the regular ``buildout.cfg`` so that we do not have
435to repeat most sections but the ``parts`` in ``[buildout]`` have to be
436listed.
437
438We need, however, not everything with a ZEO-deploy that is listed in a
439default buildout. We might do not need docs, no profiling, etc. Also a
440regular non-ZEO kofactl might not make to much sense. Therefore all
441this might be subject to changes.
442
443.. _Debian: http://www.debian.org/
444.. _Grok: http://grok.zope.org/
445.. _Python: http://www.python.org/
446.. _Subversion: http://subversion.apache.org/
447.. _Ubuntu: http://www.ubuntu.com/
448.. _virtualenv: http://www.virtualenv.org/en/latest/
449.. _WAeUP: https://www.waeup.org/
450.. _Zope: http://www.zope.org/
451.. _zc.buildout: http://cheeseshop.python.org/pypi/zc.buildout
Note: See TracBrowser for help on using the repository browser.