Trac

From Gentoo Linux Wiki

Jump to: navigation, search
Please format this article according to the Style Guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article.

Reason(s):

  • fastcgi/cgi need to complete

Contents

[edit] Introduction

To use the Trac not only as a wiki you need a running svn repository.

[edit] Installation

[edit] Preconditions

You need to have the following packages installed.

dev-util/subversion

www-servers/apache

Note: Mod Python for Apache is only needed if you plan to use this for your trac environment.

www-apache/mod_python

[edit] Trac

To install the www-apps/trac package you have to execute the command below as root.

emerge -a trac

[edit] Configuration

[edit] Create Environment

First you need to initiate a trac environment with the trac-admin tool.

trac-admin /var/lib/trac/my_trac initenv

Now you follow the instructions.

Note: For the database connection string have a look at the backend section here.
Warning: The script will ask you for the svn path. Don't gives the svn root path here. It must be an existing repository.


Note: For a fast test, you can use the tracd webserver to test the new environment
tracd --port 8000 /var/lib/trac/my_trac

[edit] Backends

[edit] sqlite

Code: trac-admin /var/lib/trac/my_trac initenv

sqlite:db/trac.db

sqlite - database type

db/trac.db - relative path to the database of our trac environment

Set the read and write permission for the sqlite db to the apache user.

Note: Do this immediately after the initenv command.
chown apache:apache /var/lib/trac/my_trac/db/trac.db
chmod 0770 /var/lib/trac/my_trac/db/trac.db
chown apache:apache /var/lib/trac/my_trac/db

[edit] postgres

Create a user who is allowed to create schemas in a database.

su - postgres
createuser -S -D -R -E --host=localhost <YourPostgresUser>

Create the database where the user above is allowed to create schemas and tables

su - postgres
createdb --owner=<YourPostgresUser> --host=localhost <YourDatabaseName>
Note: Don't create the schema by your self. Trac will do that.

Now you can initiate the trac environment.

Connection string

Code: trac-admin /var/lib/trac/my_trac initenv

postgres://user:pass@localhost:5432/dbname?schema=schemaname

or (Unix Socket)

Code: trac-admin /var/lib/trac/my_trac initenv

postgres://user:pass@/dbname?host=/path/to/unix/socket/dir&schema=schemaname

[edit] mysql (unstable)

Connection string

Code: trac-admin /var/lib/trac/my_trac initenv

mysql://dbuser:dbpass@host:port/dbname

or (Unix Socket)

Code: trac-admin /var/lib/trac/my_trac initenv

mysql://user:pass@/dbname?host=/path/to/unix/socket

Create the database

mysqladmin create dbname
mysql
grant all privileges on dbname.* to dbuser@dbhost identified by 'dbpass';
use dbname;
ALTER DATABASE DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
quit;

[edit] Single Project

[edit] mod_python

[edit] default host
File: /etc/apache/vhosts/default_vhost.include
        <LocationMatch "/trac">
                SetEnv PYTHON_EGG_CACHE /var/lib/trac/egg-cache
                SetHandler mod_python
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnv /var/lib/trac/
                PythonOption TracUriRoot /trac/
        </LocationMatch>

        <LocationMatch "/trac/[^/]+/login">
                AuthType Basic
                AuthName "Trac Server"
                AuthUserFile /var/svn/conf/svnusers
                Require valid-user
        </LocationMatch>
[edit] vhost
File: /etc/apache/vhosts/my_vhost.include
        <LocationMatch "/">
                SetEnv PYTHON_EGG_CACHE /var/lib/trac/egg-cache
                SetHandler mod_python
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnv /var/lib/trac/
                PythonOption TracUriRoot /
        </LocationMatch>

        <LocationMatch "/[^/]+/login">
                AuthType Basic
                AuthName "Trac Server"
                AuthUserFile /var/svn/conf/svnusers
                Require valid-user
        </LocationMatch>
Note: Above gave me a "Internal server error" and a failed python assert in the apache logs. I needed: PythonOption TracEnv /var/lib/trac/my_trac

[edit] cgi/fastcgi

[edit] default host
[edit] vhost

[edit] Multiple Projects

[edit] mod_python

[edit] default host
File: /etc/apache/vhosts/default_vhost.include
        <LocationMatch "/trac">
                SetEnv PYTHON_EGG_CACHE /var/lib/trac/egg-cache
                SetHandler mod_python
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnvParentDir /var/lib/trac/
                PythonOption TracUriRoot /trac/
        </LocationMatch>

        <LocationMatch "/trac/[^/]+/login">
                AuthType Basic
                AuthName "Trac Server"
                AuthUserFile /var/svn/conf/svnusers
                Require valid-user
        </LocationMatch>
[edit] vhost
File: /etc/apache/vhosts/my_vhost.include
        <LocationMatch "/">
                SetEnv PYTHON_EGG_CACHE /var/lib/trac/egg-cache
                SetHandler mod_python
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnvParentDir /var/lib/trac
                PythonOption TracUriRoot /
        </LocationMatch>

        <LocationMatch "/[^/]+/login">
                AuthType Basic
                AuthName "Trac Server"
                AuthUserFile /var/svn/conf/svnusers
                Require valid-user
        </LocationMatch>


[edit] cgi/fastcgi

[edit] default host
[edit] vhost

[edit] Permissions

For the Authorization we use the AuthBasic from Apache here. You can use other methods, too.

At first you need to create the "svnusers" passwd file for the apache.

Note: For other users you don't need the "-c" argument.
htpasswd2 -c -s -b /var/svn/conf/svnusers user1 password1
htpasswd2 -s -b /var/svn/conf/svnusers user2 password2

Now you have to change the permissions for the file /var/svn/conf/svnusers.

chown root:apache /var/svn/conf/svnusers
chmod 0640 /var/svn/conf/svnusers
chown root:apache /var/svn/conf
chmod 0650 /var/svn/conf

Now you need to give one or more of your created users admin permission. This you must do it for every trac environment.

trac-admin /var/lib/trac/repos1/ permission add user1 TRAC_ADMIN
trac-admin /var/lib/trac/repos2/ permission add user2 TRAC_ADMIN

At this point you are able to configure the rest with the TRAC_ADMIN Account over the webinterface of trac.

[edit] Recommend Trac Plugins/Macros

TracNav

[edit] Recent Links

TracHacks

Originally written by: J0inty - 20.11.2008

Personal tools