# Apache vhost for Trac

## Re-JeeP

Hi!

I am trying to create an Apache vhost for a Trac. I have read the wiki but it doesn't quite help me in this matter.

I installed the Trac for my project (ipdl) in /var/lib/trac/ipdl which I tried to point the vhost to. But no success... Though if I use the builtin Trac-server (tracd --port 8000 /var/lib/trac/ipdl) it works fine.

These are the trac folders on my system. find / -name "trac" -type d:

```
/usr/lib/python2.4/site-packages/trac

/usr/portage/www-apps/trac

/usr/share/webapps/trac

/usr/share/trac

/var/lib/trac

/var/db/webapps/trac
```

I only want a minimum vhost. No password etc...

```
<VirtualHost *>

        DocumentRoot "/..../"

        ServerName ipdl.tuxicity.se

</VirtualHost>

<Directory /.../>

        Order allow,deny

        Allow from all

</Directory>
```

emerge -pv www-apps/trac

```
These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] www-apps/trac-0.10.3.1  USE="enscript mysql silvercity sqlite vhosts -cgi -fastcgi -postgres" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB
```

Thanks!

----------

## gerdesj

Here's how I do it.  Note the TRAC_ENV:

```
# TRAC

      ScriptAlias /trac /var/www/<VHOST>/cgi-bin/trac.fcgi

      <Location "/trac">

        SetEnv TRAC_ENV "/var/lib/trac/<TRAC INSTANCE>"

       ..... auth stuff removed ...

      </Location>

# /TRAC
```

Adjust to taste ie <VHOST> and <TRAC INSTANCE>.

Cheers

Jon

----------

## Re-JeeP

Hi!

As you can see from my USE-flags I left out cgi and fastcgi. And in your config you use that (/var/www/<VHOST>/cgi-bin/trac.fcgi). Is that something I have missed?

And why should I even need anything else than just point to /var/lib/trac/ipdl in my conf? Why isn't that my vhost dir?

```
<VirtualHost *>

        DocumentRoot "/var/www/ipdl"

        ServerName ipdl.tuxicity.se

        ScriptAlias /trac /var/www/ipdl

        <Location "/trac">

                SetEnv TRAC_ENV "/var/lib/trac/ipdl"

        </Location>

</VirtualHost>

<Directory /var/www/ipdl>

        Order allow,deny

        Allow from all

</Directory>
```

----------

## fugue88

 *Re-JeeP wrote:*   

> As you can see from my USE-flags I left out cgi and fastcgi. And in your config you use that (/var/www/<VHOST>/cgi-bin/trac.fcgi). Is that something I have missed?

 

I've got several Tracs setup on my server, and use FastCGI to do it.  It works fairly well, and I recommend it.

 *Re-JeeP wrote:*   

> And why should I even need anything else than just point to /var/lib/trac/ipdl in my conf? Why isn't that my vhost dir?

 

/var/lib/trac/ipdl is where the Trac environment would be installed.  The environment includes Tracs database, configuration, and plugins.  These files aren't served out directly as files (and so aren't your DocumentRoot), but are used by Trac to generate pages to serve out, so Trac needs to know where they are (by setting the TRAC_ENV variable).

Some files may be served out directly by Apache (like the CSS and images files), or used or invoked by Apache (like the .fcgi script), and so Apache needs to know where those files are, by setting DocumentRoot and so on.

Trac's very flexible, so it's hard to understand what goes where and why.

----------

## Nick C

Theres a reasonable guide over on the wiki that explains how to setup trac for vhosts, its not perfect as its largely based on what the author wants his config to do, but it is a decent starting place.

http://gentoo-wiki.com/HOWTO_Trac

----------

## Re-JeeP

 *Nick C wrote:*   

> Theres a reasonable guide over on the wiki that explains how to setup trac for vhosts, its not perfect as its largely based on what the author wants his config to do, but it is a decent starting place.
> 
> http://gentoo-wiki.com/HOWTO_Trac

 

Yes! I have read that and according to me that guide sucks. I solved it with way less Apache conf than in the guide:

```
<Location /project>

        SetEnv TRAC_ENV "/var/lib/trac/project"

</Location>

<Location /project>

        AuthType Basic

        AuthName "project::trac"

        AuthUserFile /var/lib/trac/project/trac.passwd

        Require valid-user

</Location>

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

This works like a charm!   :Very Happy: 

----------

