Edgewall Software

Changes between Version 21 and Version 22 of TracOnGentoo


Ignore:
Timestamp:
Mar 21, 2005, 10:22:05 AM (19 years ago)
Author:
lycos42@…
Comment:

layout

Legend:

Unmodified
Added
Removed
Modified
  • TracOnGentoo

    v21 v22  
    6868
    6969Let's say we want our repositories to live under /var/svn/. Issue the following commands to create a repository for project1:
    70 
     70{{{
    7171svnadmin create /var/svn/project1
    7272chown -R apache /var/svn/project1
    73 
     73}}}
    7474Changing the ownership of the repository is important: as svn commits will be handled by Apache, the apache user needs to have write access to the repository.
    7575
    7676Also, if you built Subversion from Apache 2.0.50, you may want to do the following (that's because APR from Apache 2.0.50 has a bug and set created directories to 1755 instead of regular 0755):
    77 
     77{{{
    7878find /var/svn/project1 -type d -exec chmod 755 {} \;
    79 
     79}}}
    8080Repeat these steps for each project you have.
    81813.2. Creating Trac environments
    8282
    8383Each project needs a Trac environment too, and we want them to live under /var/lib/trac/. If it doesn't already exist, we create the directory:
    84 
     84{{{
    8585mkdir /var/lib/trac/
    86 
     86}}}
    8787Then we create a Trac environment for project1 by doing:
    88 
     88{{{
    8989trac-admin /var/lib/trac/project1/ initenv
    90 
     90}}}
    9191Just answer the question to fill you needs, and indicates the right Subversion repository created in the previous step. Adjust the ownership of var/lib/trac/project1/, because Trac needs to write in it:
    92 
     92{{{
    9393chown -R apache /var/lib/trac/project1/
    94 
     94}}}
    9595Repeat the above steps for each project you have.
    96964. Configuring Apache
     
    100100
    101101The first part of the configuration is relative to the vhost itself:
    102 
     102{{{
    103103<VirtualHost *:80>
    104104        ServerName dev.domain.tld
     
    121121                </IfModule>
    122122        </Directory>
    123 
     123}}}
    124124Here I set the name-based vhost and the access policies. Note that +Indexes on htdocs/ isn't needed; however, in case webapp-config created symlinks, +FollowSymLinks is necessary, both on htdocs/ and cgi-bin/.
    1251254.2. Per-project configuration
    126126
    127127Next, there are per-project specific directives that define a project. This example has to be repeated for each project.
    128 
     128{{{
    129129        ###
    130130        ### project1
     
    166166        Alias /project1/trac /var/www/dev.domain.tld/htdocs/project1/trac
    167167        ScriptAlias /project1 /var/www/dev.domain.tld/cgi-bin/trac.cgi
    168 
     168}}}
    169169As you can see, I make a big use of Locations and Aliases. Now, some comments.
    1701704.2.1. Trac stuff
     
    173173
    174174That's why we set the TRAC_ENV for the entire /project1 web space, with the following:
    175 
     175{{{
    176176        <Location /project1>
    177177                SetEnv TRAC_ENV "/var/lib/trac/project1"
    178178        </Location>
    179 
     179}}}
    180180Then we redirect every request for /project1/* to trac.cgi with the ScriptAlias directive:
    181 
     181{{{
    182182        ScriptAlias /project1 /var/www/dev.domain.tld/cgi-bin/trac.cgi
    183 
     183}}}
    184184This needs to be placed at the very end of the project configuration, because it is a default redirection for every request made to /project1/*. Special configuration for some URIs will be placed before this directive to be taken in account.
    185185
    186186A needed escaping URI is /project1/login, used by Trac to authenticate users. I've set a Location for it, and placed the authentication stuff inside:
    187 
     187{{{
    188188        <Location /project1/login>
    189189                AuthType Basic
     
    196196                </IfModule>
    197197        </Location>
    198 
     198}}}
    199199AuthType, AuthName and Require directives are needed, then you may use the user referential you want (here I'm using a LDAP server). I'm telling Apache that a user may authenticate if he belongs to the project1 group. This way, you can create groups for each project you have, and make users belong to the groups corresponding to the projects they work on.
    200200
    201201The last thing to make Trac work is to map a URI to the images and css files location, again to escape the trac.cgi handler.
    202 
     202{{{
    203203        Alias /project1/trac /var/www/dev.domain.tld/htdocs/project1/trac
    204 
     204}}}
    205205As we installed the Trac instance to /project1/trac it should work. Well, actually we need to modify the trac.ini configuration file for Trac, in order to change the way URIs are generated. Just edit /var/lib/trac/project1/conf/trac.ini:
    206 
     206{{{
    207207htdocs_location = /project1/trac
    208 
     208}}}
    209209Ok, that should be enough to use Trac. Point a browser to http://dev.domain.tld/project1 and voila.
    2102104.2.2. External components to Trac
     
    213213
    214214We need to escape trac.cgi again, by setting a new Alias before the ScriptAlias directive. There we map the /project1/dox web space to the /var/www/dev.domain.tld/htdocs/project1/dox file space.
    215 
     215{{{
    216216        Alias /project1/dox /var/www/dev.domain.tld/htdocs/project1/dox
    217 
     217}}}
    218218By the way, I've automated the creation of the Doxygen documentation by using the post-commit hook of Subversion, and doing a checkout followed by a "doxygenation" inside /var/www/dev.domain.tld/htdocs/project1/dox.
    219219
    220220Last but not least, I wanted to make the Subversion repository accessible via /project1/svn, with anonymous checkouts and authenticated commits. We need a Location to place the mod_dav_svn stuff and the authentication directives.
    221 
     221{{{
    222222        <Location /project1/svn>
    223223                <IfDefine SVN>
     
    237237                </LimitExcept>
    238238        </Location>
    239 
     239}}}
    240240As you can see, I'm storing my Subversion repositories under /var/svn/, so I set the name of the project1 repository to /var/svn/project1. Obviously, it is the filepath I will use when I create the project1 Trac environment.
    241241
     
    244244
    245245We can use the per-project templates of Trac to integrate, for example, the Doxygen documentation inside Trac. They are located under /var/lib/trac/project1/templates/. We may want to insert a link to /project1/dox in the header, and have the following site_header.cs:
    246 
     246{{{
    247247<?cs
    248248####################################################################
     
    252252<a id="dox" href="/<?cs var:project.name?>/dox">Doxygen documentation</a>
    253253</div>
    254 
     254}}}
    255255And why not using a per-project css file? Let's edit site_css.cs:
    256 
     256{{{
    257257<?cs
    258258##################################################################
     
    260260?>
    261261@import url("<?cs var:htdocs_location ?>css/<?cs var:project.name?>.css");
    262 
     262}}}
    263263This way, we can create a /var/www/dev.domain.tld/htdocs/project1/trac/css/project1.css file (among with symlinks), and personalize the Trac layout. These per-projects file won't be deleted by webapp-config, so it's a good thing.
    2642645. Conclusion