Changes between Version 21 and Version 22 of TracOnGentoo
- Timestamp:
- Mar 21, 2005, 10:22:05 AM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracOnGentoo
v21 v22 68 68 69 69 Let's say we want our repositories to live under /var/svn/. Issue the following commands to create a repository for project1: 70 70 {{{ 71 71 svnadmin create /var/svn/project1 72 72 chown -R apache /var/svn/project1 73 73 }}} 74 74 Changing 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. 75 75 76 76 Also, 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 {{{ 78 78 find /var/svn/project1 -type d -exec chmod 755 {} \; 79 79 }}} 80 80 Repeat these steps for each project you have. 81 81 3.2. Creating Trac environments 82 82 83 83 Each 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 {{{ 85 85 mkdir /var/lib/trac/ 86 86 }}} 87 87 Then we create a Trac environment for project1 by doing: 88 88 {{{ 89 89 trac-admin /var/lib/trac/project1/ initenv 90 90 }}} 91 91 Just 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 {{{ 93 93 chown -R apache /var/lib/trac/project1/ 94 94 }}} 95 95 Repeat the above steps for each project you have. 96 96 4. Configuring Apache … … 100 100 101 101 The first part of the configuration is relative to the vhost itself: 102 102 {{{ 103 103 <VirtualHost *:80> 104 104 ServerName dev.domain.tld … … 121 121 </IfModule> 122 122 </Directory> 123 123 }}} 124 124 Here 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/. 125 125 4.2. Per-project configuration 126 126 127 127 Next, there are per-project specific directives that define a project. This example has to be repeated for each project. 128 128 {{{ 129 129 ### 130 130 ### project1 … … 166 166 Alias /project1/trac /var/www/dev.domain.tld/htdocs/project1/trac 167 167 ScriptAlias /project1 /var/www/dev.domain.tld/cgi-bin/trac.cgi 168 168 }}} 169 169 As you can see, I make a big use of Locations and Aliases. Now, some comments. 170 170 4.2.1. Trac stuff … … 173 173 174 174 That's why we set the TRAC_ENV for the entire /project1 web space, with the following: 175 175 {{{ 176 176 <Location /project1> 177 177 SetEnv TRAC_ENV "/var/lib/trac/project1" 178 178 </Location> 179 179 }}} 180 180 Then we redirect every request for /project1/* to trac.cgi with the ScriptAlias directive: 181 181 {{{ 182 182 ScriptAlias /project1 /var/www/dev.domain.tld/cgi-bin/trac.cgi 183 183 }}} 184 184 This 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. 185 185 186 186 A 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 {{{ 188 188 <Location /project1/login> 189 189 AuthType Basic … … 196 196 </IfModule> 197 197 </Location> 198 198 }}} 199 199 AuthType, 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. 200 200 201 201 The 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 {{{ 203 203 Alias /project1/trac /var/www/dev.domain.tld/htdocs/project1/trac 204 204 }}} 205 205 As 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 {{{ 207 207 htdocs_location = /project1/trac 208 208 }}} 209 209 Ok, that should be enough to use Trac. Point a browser to http://dev.domain.tld/project1 and voila. 210 210 4.2.2. External components to Trac … … 213 213 214 214 We 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 {{{ 216 216 Alias /project1/dox /var/www/dev.domain.tld/htdocs/project1/dox 217 217 }}} 218 218 By 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. 219 219 220 220 Last 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 {{{ 222 222 <Location /project1/svn> 223 223 <IfDefine SVN> … … 237 237 </LimitExcept> 238 238 </Location> 239 239 }}} 240 240 As 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. 241 241 … … 244 244 245 245 We 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 {{{ 247 247 <?cs 248 248 #################################################################### … … 252 252 <a id="dox" href="/<?cs var:project.name?>/dox">Doxygen documentation</a> 253 253 </div> 254 254 }}} 255 255 And why not using a per-project css file? Let's edit site_css.cs: 256 256 {{{ 257 257 <?cs 258 258 ################################################################## … … 260 260 ?> 261 261 @import url("<?cs var:htdocs_location ?>css/<?cs var:project.name?>.css"); 262 262 }}} 263 263 This 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. 264 264 5. Conclusion