| 2 | [[PageOutline]] |
| 3 | = Installing Trac on Ubuntu |
| 4 | This is a short recipe to install and configure virtual `Apache2` host with `Trac` |
| 5 | == What are Ubuntu packages needed |
| 6 | Typical procedure to install Trac under Ubuntu with its default dependencies (default - choosed by apt) is |
| 7 | {{{#!sh |
| 8 | apt-get install python python-babel |
| 9 | apt-get install trac |
| 10 | }}} |
| 11 | Ensure that python version matches Trac latest, otherwise apt will install older Trac version which matches your old python package installed. Also take into account that `python-babel` should be always installed before `trac` if you wish to see it internationalized. |
| 12 | === Upgrade python packages |
| 13 | Ubuntu pre-packaged python resources are not always newest, and you may consider to upgrade them with `easy_install` or `pip` |
| 14 | - Upgrade with `easy_install` |
| 15 | {{{#!sh |
| 16 | easy_install Babel |
| 17 | easy_install Trac |
| 18 | }}} |
| 19 | - Upgrade with `pip` (another python installer, namely `python-pip`) |
| 20 | {{{#!sh |
| 21 | apt-get install python-pip |
| 22 | pip install --upgrade Babel |
| 23 | pip install --upgrade Trac |
| 24 | }}} |
| 25 | == Configuring virtual host |
| 26 | Here is shown sample virtual host configuration running under `apache2` (one file) with minimal, "entry level" settings. |
| 27 | Config file created at `apache2` known place for site configs (see below), and then configured site can be "enabled" to run. |
| 29 | The following considerations used within this config, yours may vary, so adjust them below appropriately at your own |
| 30 | - `trac.local` is a hostname of virtual host |
| 31 | - `/var/local/trac` is a directory (Trac project) at that host |
| 32 | - `/var/local/trac/.htpasswd` is a password file created with `htpasswd` utility |
| 33 | - `ru_RU.UTF8` is a locale ident |
| 34 | === Prepare configuration |
| 35 | First you need to |
| 36 | - create directory for Trac project and change its access permissions to that under which `apache2` runs (`www-data` in most cases) |
| 37 | - initialize `Trac` environment within that directory |
| 38 | - create `apache2` htpasswd entry for authorized web user access within this directory |
| 39 | - add to Trac this authorized web user with administartive privileges over Trac |
| 40 | {{{#!sh |
| 41 | mkir -p /var/local/trac && chown www-data: /var/local/trac |
| 42 | htpasswd -c /var/local/trac/.htpasswd adminusername |
| 43 | trac-admin /var/local/trac initenv |
| 44 | trac-admin /var/local/trac permission add adminusername TRAC_ADMIN |
| 45 | }}} |
| 46 | Create config file with any text editor (`vi` in this example): |
| 47 | {{{#!sh |
| 48 | vi /etc/apache2/sites-available/trac |
| 49 | }}} |
| 50 | Enter the following copy-paste into this file: |
| 51 | {{{#!text/html |
| 52 | <VirtualHost *:80> |
| 53 | ServerName trac.local |
| 54 | <Location /> |
| 55 | SetHandler mod_python |
| 56 | PythonInterpreter main_interpreter |
| 57 | PythonHandler trac.web.modpython_frontend |
| 58 | PythonOption TracEnv /var/local/trac |
| 59 | PythonOption TracEnvParentDir /var/local/trac |
| 60 | PythonOption TracUriRoot / |
| 61 | PythonOption TracEnv /var/local/trac |
| 62 | # PythonOption TracEnvIndexTemplate /var/local/trac/templates/index-template.html |
| 63 | PythonOption TracLocale ru_RU.UTF8 |
| 64 | PythonOption PYTHON_EGG_CACHE /tmp |
| 65 | Order allow,deny |
| 66 | Allow from all |
| 67 | </Location> |
| 68 | <Location /login> |
| 69 | AuthType Basic |
| 70 | AuthName "myproject" |
| 71 | AuthUserFile /var/local/trac/.htpasswd |
| 72 | Require valid-user |
| 73 | </Location> |
| 74 | </VirtualHost> |
| 75 | }}} |
| 76 | === Enable prepared configuration |
| 77 | {{{#!sh |
| 78 | a2enmod python |
| 79 | a2ensite trac |
| 80 | service apache restart |
| 81 | }}} |
| 82 | = done. |