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