# Trac

## bjchamb

Can anyone provide any guidance on how to get trac working?  I have it installed, but I can't figure out the correct way to connect it the subversion repository and apache.  (I.E what to put in what files and what commands to issue to do it the 'gentoo' way).

----------

## exhuma.twn

I second this request. I emerged trac, but now what.... the trac homepage has no "INSTALL" doc anywhere... They actually say. We don't give support  :Sad: 

The software would be really useful to us, but I have not the time to tinker around with things until they are working.

Is nobody willing to write a step-by-step guide to get trac working on gentoo?

There is a postinstall document of trac which I read, but following it to the letter left me with an "Internal Server Error"  :Sad:  And what is ${MY_HOSTROOT} in there supposed to be anyway?!? I tried to put in the document root of my installation. That's all I could think of. I have to say. No matter how nice the software, if you can't get it running without having to guess too many things it won't be used by the majority..... and a small guide (I reckon it only takes 2-3 steps anyway) would not hurt at all. Bad marketing choice guys!  :Mad: 

My knowledge so far on this (out of the docs I could find):

 emerge trac

 run "trac-admin ${MY_HOSTROOT}/trac/<project-name> initenv"

here you are forced to guess for the first time

 create a security file: htpasswd2 -c ${MY_HOSTROOT}/trac.passwd <user>

no MD5 ?!?

 create a .htaccess file (WHERE?!? -- second guess)

```
        <Location "/cgi-bin/trac.cgi">

                SetEnv TRAC_ENV ${MY_HOSTROOT}/trac/<project-name>

        </Location>

        <Location "/cgi-bin/trac.cgi/login">

                AuthType Basic

                AuthName "trac"

                AuthUserFile ${MY_HOSTROOT}/trac.passwd

                Require valid-user

        </Location>
```

My guesses: 

 $MY_HOSTROOT = Apache's Document root

 put .htaccess file into the folder created by the first command 

As said, this left me with an Internal Server error

Anyone up to shed some light on this? Otherwise I stick to phpbt with is set up in no time.

----------

## bsdvodsky

Install trac and all its dependacies.

```
emerge trac -av
```

Once everything compiled and installed successfully, lets check apache.

```
/etc/init.d/apache2 start
```

If you get an error regarding the log directory or file, issue the following command and start the apache daemon again.

```
mkdir /var/log/apache2
```

Now lets install the templates, styles, and images for trac. The following command will place a directory called 'trac' under '/var/www/localhost/htdocs' and place the trac.cgi script under '/var/www/localhost/cgi-bin'

```
webapp-config -I -h localhost -d trac trac 0.8
```

Now lets create the svn repo that will be used by the Trac project which we'll create next. I will call the project 'foobaz' and will store the svn repo under '/opt/svn/foobaz'.

```
mkdir -p /opt/svn/foobaz

svnadmin create /opt/svn/foobaz
```

Now that we have our svn repo, lets create our Trac project. Like our svn repo, I will call the project 'foobaz' and will store the Trac project under '/opt/trac/foobaz'.

```
mkdir /opt/trac

trac-admin /opt/trac/foobaz initenv

// Trac-admin will ask you three simple questions:

// 1) The name of your project. This name will appear at the title of the Trac project page.

// 2) The path to the project's svn repo. In this example: '/opt/svn/foobaz'.

// 3) The Templates Dir. Unless you have a set of custom templates, just hit enter.
```

Now for the fun part, the apache config.

```
// add the following around line 45 in: /etc/apache2/conf/commonapache2.conf

###

### Project FOOBAZ!

###

#

# This section is only needed if you want to use apache/webdav to serve the repo as opposed

# to using svnserve. Before you can use apache/webdav however, you must uncomment this

# section and edit /etc/conf.d/apache2 to add APACHE2_OPTS="-D SVN -D DAV".

#

#<Location /foobaz/svn>

#        <IfDefine SVN>

#                 DAV svn

#                 SVNPath /opt/svn/foobaz

#                 SVNAutoversioning On

#        </IfDefine>

#        <LimitExcept GET PROPFIND OPTIONS REPORT>

#                 AuthType Basic

#                 AuthName "foobaz::svn"

#                 AuthUserFile /opt/trac/foobaz/trac.passwd

#                 Require valid-user

#        </LimitExcept>

#</Location>

<Location /foobaz>

        SetEnv TRAC_ENV "/opt/trac/foobaz"

</Location>

<Location /foobaz/login>

        AuthType Basic

        AuthName "foobaz::trac"

        AuthUserFile /opt/trac/foobaz/trac.passwd

        Require valid-user

</Location>

ScriptAlias /foobaz "/var/www/localhost/cgi-bin/trac.cgi"
```

We'll create an authenticated user named 'quido' to log into Trac and the dav/svn repo if you enabled it. Then we'll finish up by changing the permissions & ownership of the main svn repo and Trac project directories.

```
htpasswd2 -c /opt/trac/foobaz/trac.passwd quido

chmod -R 755 /opt/svn /opt/trac

chown -R apache:apache /opt/svn /opt/trac
```

Restart apache and open http://localhost/foobaz.

Well, there you have it! A simple procedure to get started with Trac. I've also included the resources I used in forming much of the information above. I'm sorry but I have to say, it took me longer to write up this post than it did to get it running.. Anyway.. How about someone adding this to the wiki!  :Wink: 

http://projects.edgewall.com/trac/wiki/TracInstall

http://home.dju.elegiac.net/wiki/wiki/MultipleTracInstancesOnGentoo

http://gentoo-wiki.com/HOWTO_Subversion

----------

## bsdvodsky

Just tried http://projects.edgewall.com/trac/wiki/TracMultipleProjects and it works great!

So in place of the config in /etc/apache2/conf/commonapache2.conf above. Use this instead:

```
RewriteEngine on

RewriteRule ^/projects/+$                       /projects/index.html [L]

RewriteCond /opt/trac/$1                        -d

RewriteRule ^/projects/([[:alnum:]]+)(/?.*)     /projects/trac.cgi$2 [S=1,E=TRAC_ENV:/opt/trac/$1]

RewriteRule ^/projects/(.*)                     /projects/index.html

<Directory "/var/www/localhost/htdocs/projects">

        AllowOverride None

        Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

        AddHandler cgi-script .cgi

        Order allow,deny

        Allow from all

</Directory>

<LocationMatch "/projects/[[:alnum:]]+/login">

        AuthType Basic

        AuthName "trac"

        AuthUserFile /opt/trac/trac.passwd

        Require valid-user

</LocationMatch>
```

Then:

```
mkdir -p /var/www/localhost/htdocs/projects

ln -s /var/www/localhost/cgi-bin/trac.cgi /var/www/localhost/htdocs/projects/trac.cgi

echo '<html><body><h1>Trac Project Missing!</h1></body></html>' > /var/www/localhost/htdocs/projects/index.html
```

Doing this will allow you to add Trac projects by simply following the 5th and 6th steps of the example above, without having to modify the apache conf. Also note that I moved the location of the AuthUseFile.

----------

## Molerat

Thanks for the useful tutorial bsdvodsky, Trac is a really neat program.

----------

## drakos7

Odd problem here. I can get to the trac page only once. After that I get  the 

```
Oops...

Trac detected an internal error:

unable to open database file

...
```

Thoughts?  :Question: 

I have trac installed in a vhost environment, but it is the only copy. I only need one.

editNevermind. I had pysqlite 0.5 and 1.0 is needed for trac.

----------

## exhuma.twn

Thanks. All is working now  :Smile: 

----------

## kdvgent

Thanks bsdvosky for the clear instructions.

I have been able to follow them till you start editing /etc/apache2/conf/commonapache2.conf - because that file is not installed on

my machine.

I have installed apache 2.0.55 via the "emerge apache" command but that file is not installed.

Help please.

----------

## kashani

commonapache and apache.conf was rolled into httpd.conf a couple of releases ago. It was done to make Gentoo Apache work a bit better with modules that expected a httpd.conf and some other things like that. The same instrutions shoudl apply to httpd.conf now though the line numbers may be off.

kashani

----------

## SNovotny

I went through the instructions and was just about to test it, but for some reason trac.cgi never got created anywhere?  I tried unmerging and emerging again, ideas?  :Neutral: 

EDIT: NM, I figured it out.Last edited by SNovotny on Thu Jan 19, 2006 2:51 am; edited 1 time in total

----------

## newtonian

Just thought I'd add this for anyone interested.

I often get  "user mypassword not found" in my apache error logs when setting up new 

trac/subversion projects.  To fix the problem I run the following and everything 

works ok:

```
chown apache -R /var/svn/projectName/
```

Cheers,

----------

## matttions

Anyone knows a way to delete all the stuff trac guide in a smart way ?

----------

## Pistos

 *SNovotny wrote:*   

> I went through the instructions and was just about to test it, but for some reason trac.cgi never got created anywhere?  I tried unmerging and emerging again, ideas? 
> 
> EDIT: NM, I figured it out.

 

Would you mind sharing your out-figuring with us?   :Smile:   I have this exact problem, I can't find trac.cgi anywhere...

EDIT:

Well, I just searched the web, and got it from the repository:

http://projects.edgewall.com/trac/browser/tags/trac-0.9.3/cgi-bin/trac.fcgi?format=raw

Seems to be working so far...

----------

## rasmussen

 *Pistos wrote:*   

> Would you mind sharing your out-figuring with us?    I have this exact problem, I can't find trac.cgi anywhere...

 

Try reemerging with USE=cgi to get the trac.cgi and USE=fastcgi to get the trac.fcgi

HTH

----------

## Pistos

 *rasmussen wrote:*   

>  *Pistos wrote:*   Would you mind sharing your out-figuring with us?    I have this exact problem, I can't find trac.cgi anywhere... Try reemerging with USE=cgi to get the trac.cgi and USE=fastcgi to get the trac.fcgi

  This made trac.fcgi come up, yes.  Thanks.

----------

