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