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