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